summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-11-17 22:29:28 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-11-17 22:29:28 (GMT)
commit5439458a2a5f4da38eeef2007f400152148fe04f (patch)
treeae4fac480be7eebcf123d1c9da331489c212e199
parentffdb2c21b34253077001a0181c2fe1f4e4b2be15 (diff)
parent6d5ad227a50c6c5a78e48a98095788953ab49512 (diff)
downloadcpython-5439458a2a5f4da38eeef2007f400152148fe04f.zip
cpython-5439458a2a5f4da38eeef2007f400152148fe04f.tar.gz
cpython-5439458a2a5f4da38eeef2007f400152148fe04f.tar.bz2
Issue #16215: Fix potential double memory free in str.replace().
Patch by Serhiy Storchaka.
-rw-r--r--Misc/NEWS3
-rw-r--r--Objects/unicodeobject.c2
2 files changed, 5 insertions, 0 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index aa9f6c7..df8f014 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ What's New in Python 3.4.0 Alpha 1?
Core and Builtins
-----------------
+- Issue #16215: Fix potential double memory free in str.replace(). Patch
+ by Serhiy Storchaka.
+
- Issue #16290: A float return value from the __complex__ special method is no
longer accepted in the complex() constructor.
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 7856e77..dd8d7b2 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -9959,6 +9959,7 @@ replace(PyObject *self, PyObject *str1,
/* widen self and buf1 */
rkind = kind2;
if (release1) PyMem_Free(buf1);
+ release1 = 0;
sbuf = _PyUnicode_AsKind(self, rkind);
if (!sbuf) goto error;
srelease = 1;
@@ -10020,6 +10021,7 @@ replace(PyObject *self, PyObject *str1,
if (!sbuf) goto error;
srelease = 1;
if (release1) PyMem_Free(buf1);
+ release1 = 0;
buf1 = _PyUnicode_AsKind(str1, rkind);
if (!buf1) goto error;
release1 = 1;