bpo-29683 - Fixes to _PyCode_SetExtra when co_extra->ce->extras is allocated#376
bpo-29683 - Fixes to _PyCode_SetExtra when co_extra->ce->extras is allocated#376vstinner merged 1 commit intopython:masterfrom
Conversation
|
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately our records indicate you have not signed the CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow these steps to rectify the issue:
Thanks again to your contribution and we look forward to looking at it! |
|
@brianfcoleman, thanks for your PR! By analyzing the history of the files in this pull request, we identified @brettcannon, @avassalotti, @gvanrossum, @1st1 and @vadmium to be potential reviewers. |
Objects/codeobject.c
Outdated
There was a problem hiding this comment.
Previously allocated co_extra->ce_extras is leaked if PyMem_Realloc() returns NULL. It would be better to save the result of PyMem_Realloc() to the variable and check it for NULL first than assign it to co_extra->ce_extras.
There was a problem hiding this comment.
I have made this change
Objects/codeobject.c
Outdated
There was a problem hiding this comment.
Would not be better to deallocate o->co_extra and set it to NULL rather of setting co_extra->ce_size to 0?
Objects/codeobject.c
Outdated
|
@brianfcoleman, please sign the CLA and add an entry in Misc/NEWS. |
4aed1c0 to
45c3243
Compare
serhiy-storchaka
left a comment
There was a problem hiding this comment.
LGTM except minor details of Misc/NEWS entry.
Misc/NEWS
Outdated
There was a problem hiding this comment.
New entries usually added are added at the start of corresponding section, so that entries are list in reversed chronological order.
It is recommended to use two spaces after sentence-ending period.
There was a problem hiding this comment.
I've made this change
allocated. On PyMem_Realloc failure, _PyCode_SetExtra should free co_extra if co_extra->ce_extras could not be allocated. On PyMem_Realloc success, _PyCode_SetExtra should set all unused slots in co_extra->ce_extras to NULL.
|
Thanks @brianfcoleman for your contribution! Would you mind to backport the change to Python 3.6? |
Bumps [codecov](https://github.com/codecov/codecov-python) from 2.1.7 to 2.1.9. - [Release notes](https://github.com/codecov/codecov-python/releases) - [Changelog](https://github.com/codecov/codecov-python/blob/master/CHANGELOG.md) - [Commits](codecov/codecov-python@v2.1.7...v2.1.9) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: Mariatta <Mariatta@users.noreply.github.com>
On PyMem_Malloc failure, _PyCode_SetExtra should set co_extra->ce_size = 0.
On PyMem_Realloc failure, _PyCode_SetExtra should set co_extra->ce_size = 0.
On PyMem_Realloc success, _PyCode_SetExtra should set all unused slots in co_extra->ce_extras to NULL.