Skip to content

Commit 95c1e50

Browse files
committed
SF bug #1331563 ] string_subscript doesn't check for failed PyMem_Malloc. Will backport
1 parent 5c4a9d6 commit 95c1e50

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Objects/stringobject.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,6 +1198,8 @@ string_subscript(PyStringObject* self, PyObject* item)
11981198
else {
11991199
source_buf = PyString_AsString((PyObject*)self);
12001200
result_buf = PyMem_Malloc(slicelength);
1201+
if (result_buf == NULL)
1202+
return PyErr_NoMemory();
12011203

12021204
for (cur = start, i = 0; i < slicelength;
12031205
cur += step, i++) {

0 commit comments

Comments
 (0)