mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
closes bpo-34400: Fix undefined behavior in parsetok(). (GH-4439)
Avoid undefined pointer arithmetic with NULL.
This commit is contained in:
parent
88bfd0bce0
commit
7c4ab2afb1
2 changed files with 2 additions and 1 deletions
|
|
@ -0,0 +1 @@
|
|||
Fix undefined behavior in parsetok.c. Patch by Zackery Spytz.
|
||||
|
|
@ -225,7 +225,7 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret,
|
|||
}
|
||||
else
|
||||
started = 1;
|
||||
len = b - a; /* XXX this may compute NULL - NULL */
|
||||
len = (a != NULL && b != NULL) ? b - a : 0;
|
||||
str = (char *) PyObject_MALLOC(len + 1);
|
||||
if (str == NULL) {
|
||||
err_ret->error = E_NOMEM;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue