Skip to content

Commit 769aea3

Browse files
authored
gh-120155: Fix Coverity issue in parse_string() (#120997)
1 parent 2d3187b commit 769aea3

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
@@ -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)