Skip to content

Commit a86a32f

Browse files
committed
handle possible NULL return value from PyUnicode_Substring
1 parent bae05c7 commit a86a32f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Python/pythonrun.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,6 +1375,9 @@ get_interactive_filename(PyObject *filename, Py_ssize_t count)
13751375
&& PyUnicode_ReadChar(filename, 0) == '<'
13761376
&& PyUnicode_ReadChar(filename, len - 1) == '>') {
13771377
PyObject *middle = PyUnicode_Substring(filename, 1, len-1);
1378+
if (middle == NULL) {
1379+
return NULL;
1380+
}
13781381
result = PyUnicode_FromFormat("<%U-%d>", middle, count);
13791382
Py_DECREF(middle);
13801383
} else {

0 commit comments

Comments
 (0)