Commit ccd99752 authored by Alexey Izbyshev's avatar Alexey Izbyshev Committed by Victor Stinner

bpo-34436: Fix check that disables overallocation for the last fmt specifier (GH-8826)

Reported by Svace static analyzer.
parent 65bef36f
......@@ -819,8 +819,8 @@ _PyBytes_FormatEx(const char *format, Py_ssize_t format_len,
if (v == NULL)
goto error;
if (fmtcnt < 0) {
/* last writer: disable writer overallocation */
if (fmtcnt == 0) {
/* last write: disable writer overallocation */
writer.overallocate = 0;
}
......@@ -1048,7 +1048,7 @@ _PyBytes_FormatEx(const char *format, Py_ssize_t format_len,
/* If overallocation was disabled, ensure that it was the last
write. Otherwise, we missed an optimization */
assert(writer.overallocate || fmtcnt < 0 || use_bytearray);
assert(writer.overallocate || fmtcnt == 0 || use_bytearray);
} /* until end */
if (argidx < arglen && !dict) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment