summaryrefslogtreecommitdiff
path: root/Objects
diff options
context:
space:
mode:
authorKristj?n Valur J?nsson <sweskman@gmail.com>2014-04-25 09:51:21 +0000
committerKristj?n Valur J?nsson <sweskman@gmail.com>2014-04-25 09:51:21 +0000
commitfcbb00b5e2d13f65f598d245c2d3e6b5dd4ffea9 (patch)
tree229af9d3d2e081dbb300bdbce4478f9f2d78685a /Objects
parenta6154711706d60da9fceb9ad3481ef6886b46c8a (diff)
downloadcpython-fcbb00b5e2d13f65f598d245c2d3e6b5dd4ffea9.tar.gz
Issue #20434 Correct error handlin of _PyString_Resize and _PyBytes_Resize
Diffstat (limited to 'Objects')
-rw-r--r--Objects/bytearrayobject.c6
-rw-r--r--Objects/stringobject.c4
2 files changed, 4 insertions, 6 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index 21c58ce5f4..fd0ce7c6cf 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -994,10 +994,8 @@ bytearray_repr(PyByteArrayObject *self)
*p++ = *quote_postfix++;
}
*p = '\0';
- if (_PyString_Resize(&v, (p - PyString_AS_STRING(v)))) {
- Py_DECREF(v);
- return NULL;
- }
+ /* v is cleared on error */
+ (void)_PyString_Resize(&v, (p - PyString_AS_STRING(v)));
return v;
}
}
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index 83dab085b6..0b6d36cee0 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -748,8 +748,8 @@ PyObject *PyString_DecodeEscape(const char *s,
UTF-8 bytes may follow. */
}
}
- if (p-buf < newlen && _PyString_Resize(&v, p - buf))
- goto failed;
+ if (p-buf < newlen)
+ _PyString_Resize(&v, p - buf); /* v is cleared on error */
return v;
failed:
Py_DECREF(v);