From: Victor Stinner Date: Thu, 27 Mar 2025 09:03:58 +0000 (+0100) Subject: gh-111178: Skip undefined behavior checks in _PyPegen_lookahead() (#131714) X-Git-Tag: v3.14.0a7~171 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=37968845284501a536a96b9fdafab83d43dd9b9d;p=thirdparty%2FPython%2Fcpython.git gh-111178: Skip undefined behavior checks in _PyPegen_lookahead() (#131714) For example, expression_rule() return type is 'expr_ty', whereas _PyPegen_lookahead() uses 'void*'. --- diff --git a/Parser/pegen.c b/Parser/pegen.c index 592269ead31e..75fdd467e550 100644 --- a/Parser/pegen.c +++ b/Parser/pegen.c @@ -406,11 +406,14 @@ _PyPegen_lookahead_with_int(int positive, Token *(func)(Parser *, int), Parser * return (res != NULL) == positive; } -int +// gh-111178: Use _Py_NO_SANITIZE_UNDEFINED to disable sanitizer checks on +// undefined behavior (UBsan) in this function, rather than changing 'func' +// callback API. +int _Py_NO_SANITIZE_UNDEFINED _PyPegen_lookahead(int positive, void *(func)(Parser *), Parser *p) { int mark = p->mark; - void *res = (void*)func(p); + void *res = func(p); p->mark = mark; return (res != NULL) == positive; }