]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-95876: Fix format string in pegen error location code (#95877)
authorChristian Heimes <christian@python.org>
Thu, 11 Aug 2022 08:55:57 +0000 (10:55 +0200)
committerGitHub <noreply@github.com>
Thu, 11 Aug 2022 08:55:57 +0000 (09:55 +0100)
Misc/NEWS.d/next/Core and Builtins/2022-08-11-09-19-55.gh-issue-95876.YpQfoV.rst [new file with mode: 0644]
Parser/pegen_errors.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-08-11-09-19-55.gh-issue-95876.YpQfoV.rst b/Misc/NEWS.d/next/Core and Builtins/2022-08-11-09-19-55.gh-issue-95876.YpQfoV.rst
new file mode 100644 (file)
index 0000000..96b6901
--- /dev/null
@@ -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.
index c87d50abd2c71a0b5579ef2fbcde9902b354b315..95bbd43dc326213d680c0919da9f386a0264b5bc 100644 (file)
@@ -371,7 +371,7 @@ _PyPegen_raise_error_known_location(Parser *p, PyObject *errtype,
             }
         }
     }
-    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;
     }