summaryrefslogtreecommitdiffstats
path: root/Modules/_testcapimodule.c
diff options
context:
space:
mode:
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>2010-12-08 23:31:48 (GMT)
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>2010-12-08 23:31:48 (GMT)
commite239d23e8cc66605f548585ad4489a8f12fc070d (patch)
treee165422c11006a4f3595742dd40a7a2095ef59ce /Modules/_testcapimodule.c
parent1b2bd3b348d7bb861ae8c92853e5058766ebff80 (diff)
downloadcpython-e239d23e8cc66605f548585ad4489a8f12fc070d.zip
cpython-e239d23e8cc66605f548585ad4489a8f12fc070d.tar.gz
cpython-e239d23e8cc66605f548585ad4489a8f12fc070d.tar.bz2
Issue #6697: Fixed instances of _PyUnicode_AsString() result not checked for NULL
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r--Modules/_testcapimodule.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 42d0bcd..f0c07ae 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -1741,15 +1741,16 @@ test_string_from_format(PyObject *self, PyObject *args)
{
PyObject *result;
char *msg;
-
-#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; \
- } \
+ 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 (Py_UNICODE_strcmp(PyUnicode_AS_UNICODE(result), one)) { \
+ msg = FORMAT " failed at 1"; \
+ goto Fail; \
+ } \
Py_DECREF(result)
CHECK_1_FORMAT("%d", int);