diff options
author | Christian Heimes <christian@cheimes.de> | 2013-07-26 12:52:26 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2013-07-26 12:52:26 (GMT) |
commit | 5e3de55b0130f57b659795dbda294558d18d1f09 (patch) | |
tree | 51a6ee59c88a86835c9d62c9273d3e9c49704f42 /Modules | |
parent | ef86368ea6f92af6192355fea382dc9dd65ecd1d (diff) | |
parent | ff369a5595976f8318b7418a817c850998a26233 (diff) | |
download | cpython-5e3de55b0130f57b659795dbda294558d18d1f09.zip cpython-5e3de55b0130f57b659795dbda294558d18d1f09.tar.gz cpython-5e3de55b0130f57b659795dbda294558d18d1f09.tar.bz2 |
Fix possible NULL pointer dereferences in testcapi module
CID 1058280
CID 1058282
CID 1058284
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_testcapimodule.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index ed234be..6ffe3c2 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -120,6 +120,10 @@ test_dict_inner(int count) for (i = 0; i < count; i++) { v = PyLong_FromLong(i); + if (v == NULL) { + Py_DECREF(v); + return -1; + } if (PyDict_SetItem(dict, v, v) < 0) { Py_DECREF(v); return -1; @@ -1656,6 +1660,8 @@ test_long_numbits(PyObject *self) for (i = 0; i < Py_ARRAY_LENGTH(testcases); ++i) { PyObject *plong = PyLong_FromLong(testcases[i].input); + if (plong == NULL) + return NULL; size_t nbits = _PyLong_NumBits(plong); int sign = _PyLong_Sign(plong); @@ -2248,7 +2254,7 @@ profile_int(PyObject *self, PyObject* args) gettimeofday(&start, NULL); for(i=0; i < 10000000; i++) { result = PyNumber_Add(op1, op1); - Py_DECREF(result); + Py_XDECREF(result); } gettimeofday(&stop, NULL); Py_DECREF(op1); |