mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Issue #6697: Fixed instances of _PyUnicode_AsString() result not checked for NULL
This commit is contained in:
parent
1b2bd3b348
commit
e239d23e8c
13 changed files with 144 additions and 78 deletions
|
|
@ -1741,15 +1741,16 @@ test_string_from_format(PyObject *self, PyObject *args)
|
|||
{
|
||||
PyObject *result;
|
||||
char *msg;
|
||||
static const Py_UNICODE one[] = {'1', 0};
|
||||
|
||||
#define CHECK_1_FORMAT(FORMAT, TYPE) \
|
||||
result = PyUnicode_FromFormat(FORMAT, (TYPE)1); \
|
||||
if (result == NULL) \
|
||||
return NULL; \
|
||||
if (strcmp(_PyUnicode_AsString(result), "1")) { \
|
||||
msg = FORMAT " failed at 1"; \
|
||||
goto Fail; \
|
||||
} \
|
||||
#define CHECK_1_FORMAT(FORMAT, TYPE) \
|
||||
result = PyUnicode_FromFormat(FORMAT, (TYPE)1); \
|
||||
if (result == NULL) \
|
||||
return NULL; \
|
||||
if (Py_UNICODE_strcmp(PyUnicode_AS_UNICODE(result), one)) { \
|
||||
msg = FORMAT " failed at 1"; \
|
||||
goto Fail; \
|
||||
} \
|
||||
Py_DECREF(result)
|
||||
|
||||
CHECK_1_FORMAT("%d", int);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue