summaryrefslogtreecommitdiffstats
path: root/Objects/stringobject.c
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2008-04-09 23:16:37 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2008-04-09 23:16:37 (GMT)
commitc00eb73a309d5e9a4e89c3114b32eda88bd83e98 (patch)
treefaec1107bc64ecfc8f230d9f294a02503a530e45 /Objects/stringobject.c
parentf10832005599cb78b20ccbae63adf8a9450ba2bf (diff)
downloadcpython-c00eb73a309d5e9a4e89c3114b32eda88bd83e98.zip
cpython-c00eb73a309d5e9a4e89c3114b32eda88bd83e98.tar.gz
cpython-c00eb73a309d5e9a4e89c3114b32eda88bd83e98.tar.bz2
Raise SystemError when size < 0 is passed into PyString_FromStringAndSize,
PyBytes_FromStringAndSize or PyUnicode_FromStringAndSize. [issue2587]
Diffstat (limited to 'Objects/stringobject.c')
-rw-r--r--Objects/stringobject.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index 4c36e4b..f4b4264 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -56,6 +56,11 @@ PyString_FromStringAndSize(const char *str, Py_ssize_t size)
{
register PyStringObject *op;
assert(size >= 0);
+ if (size < 0) {
+ PyErr_SetString(PyExc_SystemError,
+ "Negative size passed to PyString_FromStringAndSize");
+ return NULL;
+ }
if (size == 0 && (op = nullstring) != NULL) {
#ifdef COUNT_ALLOCS
null_strings++;