summaryrefslogtreecommitdiff
path: root/Python/formatter_unicode.c
diff options
context:
space:
mode:
authorNadeem Vawda <nadeem.vawda@gmail.com>2012-11-11 03:19:49 +0100
committerNadeem Vawda <nadeem.vawda@gmail.com>2012-11-11 03:19:49 +0100
commitc8d8929d95e792127bba42a42ccd97dee165dbd4 (patch)
tree110d2ed1ee5d0fb80b288174f519a0e24fbcd754 /Python/formatter_unicode.c
parent1705501613e48d1a0c235c5eb49e31db31029e31 (diff)
parent1672dbd709963c9b62601d4e043a9ae2ad826760 (diff)
downloadcpython-c8d8929d95e792127bba42a42ccd97dee165dbd4.tar.gz
Issue #16411: Fix a bug where zlib.decompressobj().flush() might try to access previously-freed memory.
Patch by Serhiy Storchaka.
Diffstat (limited to 'Python/formatter_unicode.c')
-rw-r--r--Python/formatter_unicode.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/Python/formatter_unicode.c b/Python/formatter_unicode.c
index aa62502dbe..0ce9862a20 100644
--- a/Python/formatter_unicode.c
+++ b/Python/formatter_unicode.c
@@ -757,7 +757,8 @@ format_string_internal(PyObject *value, const InternalFormatSpec *format,
goto done;
}
- if (format->width == -1 && format->precision == -1) {
+ if ((format->width == -1 || format->width <= len)
+ && (format->precision == -1 || format->precision >= len)) {
/* Fast path */
return _PyUnicodeWriter_WriteStr(writer, value);
}