Skip to content

Commit 2a6b67f

Browse files
authored
[3.10] gh-95876: Fix format string in pegen error location code (GH-95877 (GH-95901)
(cherry picked from commit b4c857d) Co-authored-by: Christian Heimes <[email protected]>
1 parent 9c04e25 commit 2a6b67f

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Fix format string in ``_PyPegen_raise_error_known_location`` that can lead
2+
to memory corruption on some 64bit systems. The function was building a
3+
tuple with ``i`` (int) instead of ``n`` (Py_ssize_t) for Py_ssize_t
4+
arguments.

Parser/pegen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ _PyPegen_raise_error_known_location(Parser *p, PyObject *errtype,
547547
byte_offset_to_character_offset(error_line, end_col_offset) :
548548
end_col_number;
549549
}
550-
tmp = Py_BuildValue("(OiiNii)", p->tok->filename, lineno, col_number, error_line, end_lineno, end_col_number);
550+
tmp = Py_BuildValue("(OnnNnn)", p->tok->filename, lineno, col_number, error_line, end_lineno, end_col_number);
551551
if (!tmp) {
552552
goto error;
553553
}

0 commit comments

Comments
 (0)