summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-09-28 21:54:59 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-09-28 21:54:59 (GMT)
commitf5ca1a21a52882954de256909d13a8977d70a881 (patch)
treee9d5f996daebc1bd52d044c0c49a2eff5927187b /Objects
parent7c8c1ea3ecc9e83c6916d7548fb92ff5d018b2db (diff)
downloadcpython-f5ca1a21a52882954de256909d13a8977d70a881.zip
cpython-f5ca1a21a52882954de256909d13a8977d70a881.tar.gz
cpython-f5ca1a21a52882954de256909d13a8977d70a881.tar.bz2
PyUnicode_CopyCharacters() fails if 'to' has more than 1 reference
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index ae2dbf5..af05f4c 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -631,6 +631,14 @@ PyUnicode_CopyCharacters(PyObject *to, Py_ssize_t to_start,
how_many, to_start, PyUnicode_GET_LENGTH(to));
return -1;
}
+ if (how_many == 0)
+ return 0;
+
+ if (Py_REFCNT(to) != 1) {
+ PyErr_SetString(PyExc_ValueError,
+ "Cannot modify a string having more than 1 reference");
+ return -1;
+ }
from_kind = PyUnicode_KIND(from);
to_kind = PyUnicode_KIND(to);