Mercurial > cpython-lru_cache-weakref
comparison Objects/stringlib/string_format.h @ 67791:3ef865327d7b
Issue #11302: missing type check on _string.formatter_field_name_split and _string.formatter_parser caused crash.
Originial patch by haypo, reviewed by me, okayed by Georg.
| author | Eric Smith <eric@trueblade.com> |
|---|---|
| date | Sat, 29 Jan 2011 11:15:35 +0000 |
| parents | 4c1c48b3af66 |
| children | 81d7f78a633a |
comparison
equal
deleted
inserted
replaced
| 67790:7c7ee4e11850 | 67791:3ef865327d7b |
|---|---|
| 1190 static PyObject * | 1190 static PyObject * |
| 1191 formatter_parser(PyObject *ignored, STRINGLIB_OBJECT *self) | 1191 formatter_parser(PyObject *ignored, STRINGLIB_OBJECT *self) |
| 1192 { | 1192 { |
| 1193 formatteriterobject *it; | 1193 formatteriterobject *it; |
| 1194 | 1194 |
| 1195 if (!PyUnicode_Check(self)) { | |
| 1196 PyErr_Format(PyExc_TypeError, "expected str, got %s", Py_TYPE(self)->tp_name); | |
| 1197 return NULL; | |
| 1198 } | |
| 1199 | |
| 1195 it = PyObject_New(formatteriterobject, &PyFormatterIter_Type); | 1200 it = PyObject_New(formatteriterobject, &PyFormatterIter_Type); |
| 1196 if (it == NULL) | 1201 if (it == NULL) |
| 1197 return NULL; | 1202 return NULL; |
| 1198 | 1203 |
| 1199 /* take ownership, give the object to the iterator */ | 1204 /* take ownership, give the object to the iterator */ |
| 1330 fieldnameiterobject *it; | 1335 fieldnameiterobject *it; |
| 1331 | 1336 |
| 1332 PyObject *first_obj = NULL; | 1337 PyObject *first_obj = NULL; |
| 1333 PyObject *result = NULL; | 1338 PyObject *result = NULL; |
| 1334 | 1339 |
| 1340 if (!PyUnicode_Check(self)) { | |
| 1341 PyErr_Format(PyExc_TypeError, "expected str, got %s", Py_TYPE(self)->tp_name); | |
| 1342 return NULL; | |
| 1343 } | |
| 1344 | |
| 1335 it = PyObject_New(fieldnameiterobject, &PyFieldNameIter_Type); | 1345 it = PyObject_New(fieldnameiterobject, &PyFieldNameIter_Type); |
| 1336 if (it == NULL) | 1346 if (it == NULL) |
| 1337 return NULL; | 1347 return NULL; |
| 1338 | 1348 |
| 1339 /* take ownership, give the object to the iterator. this is | 1349 /* take ownership, give the object to the iterator. this is |
