summaryrefslogtreecommitdiffstats
path: root/Objects/bytesobject.c
diff options
context:
space:
mode:
authorAlexey Izbyshev <izbyshev@ispras.ru>2018-08-23 07:50:52 (GMT)
committerVictor Stinner <vstinner@redhat.com>2018-08-23 07:50:52 (GMT)
commitccd99752675042bd5f67d332c5b0ed85ba1f2da3 (patch)
tree08083b873a5fac1b4e5c080363e370a3155f0eb3 /Objects/bytesobject.c
parent65bef36f0bc5d8c3f6a47568012df4ae5ba2ac8b (diff)
downloadcpython-ccd99752675042bd5f67d332c5b0ed85ba1f2da3.zip
cpython-ccd99752675042bd5f67d332c5b0ed85ba1f2da3.tar.gz
cpython-ccd99752675042bd5f67d332c5b0ed85ba1f2da3.tar.bz2
bpo-34436: Fix check that disables overallocation for the last fmt specifier (GH-8826)
Reported by Svace static analyzer.
Diffstat (limited to 'Objects/bytesobject.c')
-rw-r--r--Objects/bytesobject.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index 648b2a5..fb344c1 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -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) {