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

Potential memory leak if DmtxEncode is re-used #40

Open
sled opened this issue Mar 26, 2021 · 0 comments
Open

Potential memory leak if DmtxEncode is re-used #40

sled opened this issue Mar 26, 2021 · 0 comments

Comments

@sled
Copy link

sled commented Mar 26, 2021

I think dmtxEncodeDataMatrix should free the image->pxl buffer if the DmtxEncode struct is re-used, e.g.:

unsigned char str[] = "30Q324343430794<OQQ";

DmtxEncode *enc;
enc = dmtxEncodeCreate();
dmtxEncodeDataMatrix(enc, strlen(str), str);
dmtxEncodeDataMatrix(enc, strlen(str), str);
dmtxEncodeDestroy(&enc);

Here the image from the first call gets overwritten: https://github.com/dmtx/libdmtx/blob/master/dmtxencode.c#L222

The call to dmtxEncodeDestroy only deletes the second pixel buffer in my example above, see: https://github.com/dmtx/libdmtx/blob/master/dmtxencode.c#L70

I'd suggest to call dmtxImageDestroy and freeing the pixel buffer in the dmtxEncodeDataMatrix function if an image is present from a previous call.

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

1 participant