bpo-36262: Fix _Py_dg_strtod() memory leak (goto undfl)#12276
bpo-36262: Fix _Py_dg_strtod() memory leak (goto undfl)#12276vstinner merged 2 commits intopython:masterfrom vstinner:dtoa_goto_bfree
Conversation
Fix an unlikely memory leak on conversion from string to float in the function _Py_dg_strtod() used by float(str), complex(str), pickle.load(), marshal.load(), etc. Fix an unlikely memory leak in _Py_dg_strtod() on "undfl:" label: rewrite memory management in this function to always release all memory before exiting the function. Initialize variables to NULL, and set them to NULL after calling Bfree() at the "cont:" label. Note: Bfree(NULL) is well defined: it does nothing.
mdickinson
left a comment
There was a problem hiding this comment.
Changes LGTM. Is there any easy way to get a re-run of the coverity scan on this file to check that they agree that the leak is fixed?
I created an internal PR at Red Hat where we have a Coverity covscan job running. For an unknown reason, this issue was only spotted on Python 2, not on Python 3, whereas Python 2 and 3 use the same code for Python/dtoa.c (both have https://bugs.python.org/issue36262 leak). I will keep an eye on the internal PR to see if the covscan result changes. |
|
I can verify that with those changes, our internal instance of coverity scan doesn't report any leaks anymore for dtoa.c |
|
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7. |
|
Thanks for the review @mdickinson and thanks @stratakis for checking Coverity! I pushed a second minor cleanup change to make memory management a little bit more explicit. |
|
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 2.7. |
|
GH-12331 is a backport of this pull request to the 3.7 branch. |
|
GH-12332 is a backport of this pull request to the 2.7 branch. |
…H-12331) Fix an unlikely memory leak on conversion from string to float in the function _Py_dg_strtod() used by float(str), complex(str), pickle.load(), marshal.load(), etc. Fix an unlikely memory leak in _Py_dg_strtod() on "undfl:" label: rewrite memory management in this function to always release all memory before exiting the function. Initialize variables to NULL, and set them to NULL after calling Bfree() at the "cont:" label. Note: Bfree(NULL) is well defined: it does nothing. (cherry picked from commit 9776b06)
…H-12332) Fix an unlikely memory leak on conversion from string to float in the function _Py_dg_strtod() used by float(str), complex(str), pickle.load(), marshal.load(), etc. Fix an unlikely memory leak in _Py_dg_strtod() on "undfl:" label: rewrite memory management in this function to always release all memory before exiting the function. Initialize variables to NULL, and set them to NULL after calling Bfree() at the "cont:" label. Note: Bfree(NULL) is well defined: it does nothing. (cherry picked from commit 9776b06)
Fix an unlikely memory leak on conversion from string to float in the
function _Py_dg_strtod() used by float(str), complex(str),
pickle.load(), marshal.load(), etc.
Fix an unlikely memory leak in _Py_dg_strtod() on "undfl:" label:
rewrite memory management in this function to always release all
memory before exiting the function. Initialize variables to NULL, and
set them to NULL after calling Bfree() at the "cont:" label.
Note: Bfree(NULL) is well defined: it does nothing.
https://bugs.python.org/issue36262