]> granicus.if.org Git - python/commitdiff
_PyUnicodeWriter_PrepareInternal(): make the assertion more strict
authorVictor Stinner <victor.stinner@gmail.com>
Mon, 21 Sep 2015 23:01:17 +0000 (01:01 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Mon, 21 Sep 2015 23:01:17 +0000 (01:01 +0200)
Objects/unicodeobject.c

index 7c079e0799e4e9a7ab3c04373a4313b741283aa0..d0b285abac07d5f38cbb46c5641270b1710406fc 100644 (file)
@@ -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();