diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-08-23 08:14:54 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-23 08:14:54 (GMT) |
commit | 945771b3c7a08f0b2b875905d517a1566477bfaf (patch) | |
tree | 57e898f90d61f52a119e557fa13d64acb5e6e615 /Objects | |
parent | 0ef61ee7b194a1c15747d6bca3cf30a5c581e7e3 (diff) | |
download | cpython-945771b3c7a08f0b2b875905d517a1566477bfaf.zip cpython-945771b3c7a08f0b2b875905d517a1566477bfaf.tar.gz cpython-945771b3c7a08f0b2b875905d517a1566477bfaf.tar.bz2 |
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@ispras.ru>
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/bytesobject.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index 4950d01..26e59d1 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -813,8 +813,8 @@ _PyBytes_FormatEx(const char *format, Py_ssize_t format_len, goto error; } - if (fmtcnt < 0) { - /* last writer: disable writer overallocation */ + if (fmtcnt == 0) { + /* last write: disable writer overallocation */ writer.overallocate = 0; } @@ -1046,7 +1046,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) { |