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

Ensure long data column buffers are freed #306

Merged
merged 1 commit into from
Jan 26, 2023

Conversation

kadler
Copy link
Member

@kadler kadler commented Jan 9, 2023

The bind_type of the column stored in the StatementData object was not copied over to the ColumnData object created for each row. This means that the ColumnData destructor will not free the allocated buffer used with SQLGetData.

Additionally, for SQL_C_BINARY columns, the data was never freed either since the destructor only checked for SQL_C_CHAR and SQL_C_WCHAR.

Finally, because long data allocations are created using malloc/realloc, we need to set a flag to use free instead of delete[] in the destructor. On platforms we support, this shouldn't actually make any difference, but it is mandated by the spec and reduces noise in valgrind.

Signed-off-by: Kevin Adler [email protected]
Fixes #304

The bind_type of the column stored in the StatementData object was not
copied over to the ColumnData object created for each row. This means
that the ColumnData destructor will not free the allocated buffer used
with SQLGetData.

Additionally, for SQL_C_BINARY columns, the data was never freed either
since the destructor only checked for SQL_C_CHAR and SQL_C_WCHAR.

Finally, because long data allocations are created using malloc/realloc,
we need to set a flag to use free instead of delete[] in the destructor.
On platforms we support, this shouldn't actually make any difference,
but it is mandated by the spec and reduces noise in valgrind.

Signed-off-by: Kevin Adler <[email protected]>
@kadler kadler requested a review from markdirish January 9, 2023 20:34
@victorshengchen
Copy link

Good. This looks an important fix. Do we have target version/schedule to have this released?

Copy link
Contributor

@markdirish markdirish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

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

Successfully merging this pull request may close these issues.

[BUG] Memory leak on odbc 2.4.x when querying a table with columns in TEXT type of SQLite DB
3 participants