Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MEMPTR memory leak - false positives #1125

Closed
Ton-Pe opened this issue May 17, 2024 · 2 comments
Closed

MEMPTR memory leak - false positives #1125

Ton-Pe opened this issue May 17, 2024 · 2 comments

Comments

@Ton-Pe
Copy link

Ton-Pe commented May 17, 2024

Case 1:

Following code gives a false positive. Size of memptr is set inside the block and then released outside that block.

DEFINE VARIABLE mReceiveData AS MEMPTR   NO-UNDO.

IF TRUE THEN DO:
    SET-SIZE(mReceiveData) = 100.
END.

SET-SIZE(mReceiveData) = 0.

If release is done inside the same block or moved to finally-block, then issue is not raised.

Case 2:

Following code where copy-lob is done inside a nested block, gives false positive.

DEFINE VARIABLE mReceiveData AS MEMPTR   NO-UNDO.
DEFINE VARIABLE mSendData    AS MEMPTR   NO-UNDO.

IF TRUE THEN DO: // First level
    DO: // second level
        COPY-LOB mReceiveData TO mSendData.
    END.
END.


FINALLY:
    SET-SIZE (mSendData) = 0.
END FINALLY.

For a comparison, this code, where there is only one block, issue is not raised:

DEFINE VARIABLE mReceiveData AS MEMPTR   NO-UNDO.
DEFINE VARIABLE mSendData    AS MEMPTR   NO-UNDO.

IF TRUE THEN DO:
        COPY-LOB mReceiveData TO mSendData.
END.

FINALLY:
    SET-SIZE (mSendData) = 0.
END FINALLY.

This is similar to issue #1121 in DynamicObjectLeak rule

@Philippe-La
Copy link

Case 1:

Following code gives a false positive. Size of memptr is set inside the block and then released outside that block.

DEFINE VARIABLE mReceiveData AS MEMPTR   NO-UNDO.

IF TRUE THEN DO:
    SET-SIZE(mReceiveData) = 100.
END.

SET-SIZE(mReceiveData) = 0.

If release is done inside the same block or moved to finally-block, then issue is not raised.

+1

@gquerret
Copy link
Contributor

Fixed in develop branch, will be included in next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants