Skip to content

Commit 571cefd

Browse files
[3.13] gh-120155: Fix Coverity issue in parse_string() (GH-120997) (#121005)
gh-120155: Fix Coverity issue in parse_string() (GH-120997) (cherry picked from commit 769aea3) Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent f4f8a71 commit 571cefd

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Parser/string_parser.c

+5
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,14 @@ _PyPegen_parse_string(Parser *p, Token *t)
229229
PyErr_BadInternalCall();
230230
return NULL;
231231
}
232+
232233
/* Skip the leading quote char. */
233234
s++;
234235
len = strlen(s);
236+
// gh-120155: 's' contains at least the trailing quote,
237+
// so the code '--len' below is safe.
238+
assert(len >= 1);
239+
235240
if (len > INT_MAX) {
236241
PyErr_SetString(PyExc_OverflowError, "string to parse is too long");
237242
return NULL;

0 commit comments

Comments
 (0)