From 6174474bea9fe6f5f12f05a16004eabb817ce721 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 22 Sep 2015 01:01:17 +0200 Subject: [PATCH] _PyUnicodeWriter_PrepareInternal(): make the assertion more strict --- Objects/unicodeobject.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 7c079e0799..d0b285abac 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -13307,7 +13307,8 @@ _PyUnicodeWriter_PrepareInternal(_PyUnicodeWriter *writer, PyObject *newbuffer; /* ensure that the _PyUnicodeWriter_Prepare macro was used */ - assert(maxchar > writer->maxchar || length > 0); + assert((maxchar > writer->maxchar && length >= 0) + || length > 0); if (length > PY_SSIZE_T_MAX - writer->pos) { PyErr_NoMemory(); -- 2.40.0