mirror of
https://github.com/python/cpython
synced 2024-10-03 01:14:14 +00:00
[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 769aea3329
)
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
parent
a85241d76b
commit
5290e405c1
|
@ -226,9 +226,14 @@ _PyPegen_parse_string(Parser *p, Token *t)
|
||||||
PyErr_BadInternalCall();
|
PyErr_BadInternalCall();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Skip the leading quote char. */
|
/* Skip the leading quote char. */
|
||||||
s++;
|
s++;
|
||||||
len = strlen(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) {
|
if (len > INT_MAX) {
|
||||||
PyErr_SetString(PyExc_OverflowError, "string to parse is too long");
|
PyErr_SetString(PyExc_OverflowError, "string to parse is too long");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in a new issue