summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2000-04-13 14:10:44 (GMT)
committerFred Drake <fdrake@acm.org>2000-04-13 14:10:44 (GMT)
commit4e998bc6589790e08c327449c6b2864a7f9c6b5b (patch)
tree7448f74a23d873ace3d9d4ee67f74ddcbba14917 /Python
parentafe73a4687622c13246475559c6fccde2594e9f4 (diff)
downloadcpython-4e998bc6589790e08c327449c6b2864a7f9c6b5b.zip
cpython-4e998bc6589790e08c327449c6b2864a7f9c6b5b.tar.gz
cpython-4e998bc6589790e08c327449c6b2864a7f9c6b5b.tar.bz2
M.-A. Lemburg <mal@lemburg.com>:
Fixed problem with Unicode string concatenation: u = (u"abc" u"abc") previously dumped core.
Diffstat (limited to 'Python')
-rw-r--r--Python/compile.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 97ab99c..453aae3 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -984,11 +984,32 @@ parsestrplus(n)
REQ(CHILD(n, 0), STRING);
if ((v = parsestr(STR(CHILD(n, 0)))) != NULL) {
/* String literal concatenation */
- for (i = 1; i < NCH(n) && v != NULL; i++) {
- PyString_ConcatAndDel(&v, parsestr(STR(CHILD(n, i))));
+ for (i = 1; i < NCH(n); i++) {
+ PyObject *s;
+ s = parsestr(STR(CHILD(n, i)));
+ if (s == NULL)
+ goto onError;
+ if (PyString_Check(v) && PyString_Check(s)) {
+ PyString_ConcatAndDel(&v, s);
+ if (v == NULL)
+ goto onError;
+ }
+ else {
+ PyObject *temp;
+ temp = PyUnicode_Concat(v, s);
+ Py_DECREF(s);
+ if (temp == NULL)
+ goto onError;
+ Py_DECREF(v);
+ v = temp;
+ }
}
}
return v;
+
+ onError:
+ Py_XDECREF(v);
+ return NULL;
}
static void