summaryrefslogtreecommitdiffstats
path: root/Objects/stringobject.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2002-08-14 08:22:50 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2002-08-14 08:22:50 (GMT)
commiteb3f00aeebe619d1e3e74f51bf1d82309cdb2ec5 (patch)
tree26ec00486b502f9407f21aabe29ea648dd769bde /Objects/stringobject.c
parent8a8da798a5a35bb387575d696799be29c4eaa0d3 (diff)
downloadcpython-eb3f00aeebe619d1e3e74f51bf1d82309cdb2ec5.zip
cpython-eb3f00aeebe619d1e3e74f51bf1d82309cdb2ec5.tar.gz
cpython-eb3f00aeebe619d1e3e74f51bf1d82309cdb2ec5.tar.bz2
Check for trailing backslash. Fixes #593656.
Diffstat (limited to 'Objects/stringobject.c')
-rw-r--r--Objects/stringobject.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index 19c2834..a21e021 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -546,6 +546,11 @@ PyObject *PyString_DecodeEscape(const char *s,
continue;
}
s++;
+ if (s==end) {
+ PyErr_SetString(PyExc_ValueError,
+ "Trailing \\ in string");
+ goto failed;
+ }
switch (*s++) {
/* XXX This assumes ASCII! */
case '\n': break;
@@ -594,10 +599,9 @@ PyObject *PyString_DecodeEscape(const char *s,
break;
}
if (!errors || strcmp(errors, "strict") == 0) {
- Py_DECREF(v);
PyErr_SetString(PyExc_ValueError,
"invalid \\x escape");
- return NULL;
+ goto failed;
}
if (strcmp(errors, "replace") == 0) {
*p++ = '?';
@@ -608,18 +612,17 @@ PyObject *PyString_DecodeEscape(const char *s,
"decoding error; "
"unknown error handling code: %.400s",
errors);
- return NULL;
+ goto failed;
}
#ifndef Py_USING_UNICODE
case 'u':
case 'U':
case 'N':
if (unicode) {
- Py_DECREF(v);
com_error(com, PyExc_ValueError,
"Unicode escapes not legal "
"when Unicode disabled");
- return NULL;
+ goto failed;
}
#endif
default: