Skip to content

Commit 5290e40

Browse files
[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 769aea3) Co-authored-by: Victor Stinner <[email protected]>
1 parent a85241d commit 5290e40

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Parser/string_parser.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,14 @@ _PyPegen_parse_string(Parser *p, Token *t)
226226
PyErr_BadInternalCall();
227227
return NULL;
228228
}
229+
229230
/* Skip the leading quote char. */
230231
s++;
231232
len = strlen(s);
233+
// gh-120155: 's' contains at least the trailing quote,
234+
// so the code '--len' below is safe.
235+
assert(len >= 1);
236+
232237
if (len > INT_MAX) {
233238
PyErr_SetString(PyExc_OverflowError, "string to parse is too long");
234239
return NULL;

0 commit comments

Comments
 (0)