https://github.com/python/cpython/commit/5290e405c171dbf541b1cd8549d69d53d04a6bc0
commit: 5290e405c171dbf541b1cd8549d69d53d04a6bc0
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: vstinner <[email protected]>
date: 2024-06-25T19:40:08+02:00
summary:

[3.12] gh-120155: Fix Coverity issue in parse_string() (GH-120997) (#121006)

gh-120155: Fix Coverity issue in parse_string() (GH-120997)
(cherry picked from commit 769aea332940f03c3e5b1ad9badd6635c1ac992a)

Co-authored-by: Victor Stinner <[email protected]>

files:
M Parser/string_parser.c

diff --git a/Parser/string_parser.c b/Parser/string_parser.c
index 65c320c2173e92..164f715e153eca 100644
--- a/Parser/string_parser.c
+++ b/Parser/string_parser.c
@@ -226,9 +226,14 @@ _PyPegen_parse_string(Parser *p, Token *t)
         PyErr_BadInternalCall();
         return NULL;
     }
+
     /* Skip the leading quote char. */
     s++;
     len = strlen(s);
+    // gh-120155: 's' contains at least the trailing quote,
+    // so the code '--len' below is safe.
+    assert(len >= 1);
+
     if (len > INT_MAX) {
         PyErr_SetString(PyExc_OverflowError, "string to parse is too long");
         return NULL;

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to