Skip to content

memory leak in ConnectionObject_Initialize when mysql_real_connect fails #350

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

Merged
merged 3 commits into from
Mar 25, 2019

Conversation

fried
Copy link
Contributor

@fried fried commented Mar 22, 2019

Looking at mysql_real_connect on failure it does not free the memory of the passed in MYSQL* struct. only mysql_close does that.
So we can't set open=0 after we mysql_init or dealloc will not cleanup the memory.

Also if mysql_init returns NULL we are out of memory and shouldn't set open=1, or we could segfault in dealloc if we didn't seg before that.

Looking at mysql_real_connect on failure it does not free the memory of the passed in MYSQL* struct. only mysql_close does that.
So we can't set open=0 after we mysql_init or dealloc will not cleanup the memory.

Also if mysql_init returns NULL we are out of memory and shouldn't set open=1, or we could segfault in dealloc if we didn't seg before that.
@codecov
Copy link

codecov bot commented Mar 22, 2019

Codecov Report

Merging #350 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #350   +/-   ##
=======================================
  Coverage   87.14%   87.14%           
=======================================
  Files          13       13           
  Lines        1556     1556           
=======================================
  Hits         1356     1356           
  Misses        200      200

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e04c597...700b5ae. Read the comment docs.

@methane methane merged commit b66971e into PyMySQL:master Mar 25, 2019
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.

2 participants