Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4a0144c

Browse files
committed
Should check that PyObject_Str() really returned a string!
1 parent fe02efd commit 4a0144c

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Objects/stringobject.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,11 @@ PyString_Format(format, args)
900900
temp = PyObject_Str(v);
901901
if (temp == NULL)
902902
goto error;
903+
if (!PyString_Check(temp)) {
904+
PyErr_SetString(PyExc_TypeError,
905+
"%s argument has non-string str()");
906+
goto error;
907+
}
903908
buf = PyString_AsString(temp);
904909
len = PyString_Size(temp);
905910
if (prec >= 0 && len > prec)

0 commit comments

Comments
 (0)