[3.10] gh-95876: Fix format string in pegen error location code (GH-95877 (GH-95901)

(cherry picked from commit b4c857d0fd)

Co-authored-by: Christian Heimes <christian@python.org>
This commit is contained in:
Christian Heimes 2022-08-11 21:41:35 +02:00 committed by GitHub
parent 9c04e25308
commit 2a6b67f1c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Fix format string in ``_PyPegen_raise_error_known_location`` that can lead
to memory corruption on some 64bit systems. The function was building a
tuple with ``i`` (int) instead of ``n`` (Py_ssize_t) for Py_ssize_t
arguments.

View File

@ -547,7 +547,7 @@ _PyPegen_raise_error_known_location(Parser *p, PyObject *errtype,
byte_offset_to_character_offset(error_line, end_col_offset) :
end_col_number;
}
tmp = Py_BuildValue("(OiiNii)", p->tok->filename, lineno, col_number, error_line, end_lineno, end_col_number);
tmp = Py_BuildValue("(OnnNnn)", p->tok->filename, lineno, col_number, error_line, end_lineno, end_col_number);
if (!tmp) {
goto error;
}