Skip to content

Commit 7b7e032

Browse files
vstinnerseehwan80
authored andcommitted
pythongh-111178: Skip undefined behavior checks in _PyPegen_lookahead() (python#131714)
For example, expression_rule() return type is 'expr_ty', whereas _PyPegen_lookahead() uses 'void*'.
1 parent ea5a897 commit 7b7e032

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Parser/pegen.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,11 +406,14 @@ _PyPegen_lookahead_with_int(int positive, Token *(func)(Parser *, int), Parser *
406406
return (res != NULL) == positive;
407407
}
408408

409-
int
409+
// gh-111178: Use _Py_NO_SANITIZE_UNDEFINED to disable sanitizer checks on
410+
// undefined behavior (UBsan) in this function, rather than changing 'func'
411+
// callback API.
412+
int _Py_NO_SANITIZE_UNDEFINED
410413
_PyPegen_lookahead(int positive, void *(func)(Parser *), Parser *p)
411414
{
412415
int mark = p->mark;
413-
void *res = (void*)func(p);
416+
void *res = func(p);
414417
p->mark = mark;
415418
return (res != NULL) == positive;
416419
}

0 commit comments

Comments
 (0)