From: Serhiy Storchaka Date: Fri, 30 Jan 2015 21:35:03 +0000 (+0200) Subject: Issue #23055: Fixed off-by-one error in PyUnicode_FromFormatV. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5ec0bbf27dfef0d486dca1177d8c86f37969474e;p=python Issue #23055: Fixed off-by-one error in PyUnicode_FromFormatV. --- diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 2e5f5fd848..1e3b812528 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -893,7 +893,8 @@ PyUnicode_FromFormatV(const char *format, va_list vargs) } expand: if (abuffersize > 20) { - abuffer = PyObject_Malloc(abuffersize); + /* add 1 for sprintf's trailing null byte */ + abuffer = PyObject_Malloc(abuffersize + 1); if (!abuffer) { PyErr_NoMemory(); goto fail;