Skip to content

Commit 3796884

Browse files
authored
gh-111178: Skip undefined behavior checks in _PyPegen_lookahead() (#131714)
For example, expression_rule() return type is 'expr_ty', whereas _PyPegen_lookahead() uses 'void*'.
1 parent 9ef9d68 commit 3796884

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Diff for: Parser/pegen.c

+5-2
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)