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
bpo-36367: Free buffer if realloc fails in tokenize.c #12442
Conversation
9c036e5
to
dce2421
Compare
Hi @pablogsal I think there is the same issue in https://github.com/python/cpython/blob/dce242187f25b6861b08fe5d7e581efcfc49ea21/Parser/tokenizer.c#L891. Can you fix it too?
I think the cast to char * there is also not needed.
|
As far as I can tell this issue is also present on https://github.com/python/cpython/blob/dce242187f25b6861b08fe5d7e581efcfc49ea21/Parser/tokenizer.c#L963 |
Parser/tokenizer.c
Outdated
| @@ -618,7 +618,7 @@ static char * | |||
| translate_newlines(const char *s, int exec_input, struct tok_state *tok) { | |||
| int skip_next_lf = 0; | |||
| size_t needed_length = strlen(s) + 2, final_length; | |||
| char *buf, *current; | |||
| char *buf, *current, *result; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move result declaration where it's used? Python 3.8 now allows C99 ;-) (see PEP 7)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! :)
|
@remilapeyre I think for https://github.com/python/cpython/blob/dce242187f25b6861b08fe5d7e581efcfc49ea21/Parser/tokenizer.c#L891 is not a problem as is handle correctly afterwards: |
|
Thanks @pablogsal for the PR |
|
Thanks @pablogsal for the PR |
|
GH-12470 is a backport of this pull request to the 2.7 branch. |
|
GH-12471 is a backport of this pull request to the 3.7 branch. |
https://bugs.python.org/issue36367