From: Christian Heimes Date: Mon, 10 Sep 2012 09:48:41 +0000 (+0200) Subject: Fixed memory leak in error branch of formatfloat(). CID 719687 X-Git-Tag: v3.3.0rc3~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fd3023649459c5eac49f401335d43a9587da5e71;p=python Fixed memory leak in error branch of formatfloat(). CID 719687 --- diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 6d49806487..34a934d8cd 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -13237,8 +13237,10 @@ formatfloat(PyObject *v, int flags, int prec, int type, return -1; len = strlen(p); if (writer) { - if (_PyUnicodeWriter_Prepare(writer, len, 127) == -1) + if (_PyUnicodeWriter_Prepare(writer, len, 127) == -1) { + PyMem_Free(p); return -1; + } unicode_write_cstr(writer->buffer, writer->pos, p, len); writer->pos += len; }