Skip to content

Commit 11da66a

Browse files
committed
Fix undefined behavior in parsetok()
1 parent c206f0d commit 11da66a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

Parser/parsetok.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret,
225225
}
226226
else
227227
started = 1;
228-
len = b - a; /* XXX this may compute NULL - NULL */
228+
len = a != NULL && b != NULL ? b - a : 0;
229229
str = (char *) PyObject_MALLOC(len + 1);
230230
if (str == NULL) {
231231
err_ret->error = E_NOMEM;

0 commit comments

Comments
 (0)