[Python-checkins] bpo-34436: Fix check that disables overallocation for the last fmt specifier (GH-8826)
Miss Islington (bot)
webhook-mailer at python.org
Thu Aug 23 04:03:05 EDT 2018
https://github.com/python/cpython/commit/042082692b7fab7361a8c9d0fb792532bb77e293
commit: 042082692b7fab7361a8c9d0fb792532bb77e293
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2018-08-23T04:03:02-04:00
summary:
bpo-34436: Fix check that disables overallocation for the last fmt specifier (GH-8826)
Reported by Svace static analyzer.
(cherry picked from commit ccd99752675042bd5f67d332c5b0ed85ba1f2da3)
Co-authored-by: Alexey Izbyshev <izbyshev at ispras.ru>
files:
M Objects/bytesobject.c
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index c358756bfea8..82a75457708b 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) {
More information about the Python-checkins
mailing list