sonar-openedge icon indicating copy to clipboard operation
sonar-openedge copied to clipboard

No delete of input parameter

Open lneumeier opened this issue 7 years ago • 2 comments

Hello,

IMHO the creator of an object should be responsable for the lifecycle of an object.

Example:

METHOD VOID doNothing(oObject AS Progress.Lang.Object):
  IF VALID-OBJECT(oObject) THEN DO:
    DELETE OBJECT oObject. // this should generate a bug 
  END.
END. METHOD.

// more complex example
DEFINE VARIABLE myInputParameter AS Progress.Lang.Object NO-UNDO.
CONSTRUCTOR(oObject AS Progress.Lang.Object):
  myInputParameter = oObject.
END CONSTRUCTOR.

DESTRUCTOR():
  DELETE OBJECT myInputParameter. // this should generate a bug 
END DESTRUCTOR.

lneumeier avatar Jul 26 '18 08:07 lneumeier

I agree , unless the method is called DeleteObject ;-) . So there should be an option to suppress issue.

cverbiest avatar Jul 26 '18 08:07 cverbiest

On the other hand, if the parameter is a table-handle, then it 's a bug (memory leak) when it does not get deleted at the end of the procedure. Although the exact rules in which cases delete is required / not required are not totally clear to me (because it is also not totally clear in which cases Progress performs a deep-copy when you pass a handle or pointer).

jurjendijkstra avatar Aug 14 '18 12:08 jurjendijkstra