Skip to content

Potential memory leak if DmtxEncode is re-used #40

@sled

Description

@sled

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions