Skip to content
This repository was archived by the owner on Jan 29, 2023. It is now read-only.
This repository was archived by the owner on Jan 29, 2023. It is now read-only.

memory leak on MySQL_Connection.MySQL_Packet.buffer #18

@pabloandresm

Description

@pabloandresm

The packet buffer is allocated with the first message, and reallocated if a bigger message arrives.
So far, so good.

The problem: it is never freed.

So if your MySQL_Connection is a global variable, there is no problem. But if you used MySQL_Connection as a local variable in a function, that buffer is never freed.

The cause for this: there is no class destructor to check for this buffer and free it before the destruction of the object.

The fix? Personally, I would add a destructor in the class MySQL_Packet, that free(buffer);

Workaround for this? before exiting your function (in which MySQL_Connection local variable was created and used) perform this:
if (MySQL_Connection.buffer) free(MySQL_Connection.buffer);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions