summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2012-09-10 09:48:41 (GMT)
committerChristian Heimes <christian@cheimes.de>2012-09-10 09:48:41 (GMT)
commitfd3023649459c5eac49f401335d43a9587da5e71 (patch)
tree9a611fb19fde9fbc743d586044a5554a5e2417c3
parentbe232923e48630235da0939f5a47a3dd5908779f (diff)
downloadcpython-fd3023649459c5eac49f401335d43a9587da5e71.zip
cpython-fd3023649459c5eac49f401335d43a9587da5e71.tar.gz
cpython-fd3023649459c5eac49f401335d43a9587da5e71.tar.bz2
Fixed memory leak in error branch of formatfloat(). CID 719687
-rw-r--r--Objects/unicodeobject.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 6d49806..34a934d 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;
}