[Python-checkins] cpython (merge 3.3 -> default): Fix possible NULL pointer dereferences in testcapi module
christian.heimes
python-checkins at python.org
Fri Jul 26 14:52:37 CEST 2013
http://hg.python.org/cpython/rev/33891989c9cf
changeset: 84832:33891989c9cf
parent: 84830:3c5bf0c7a290
parent: 84831:d49f65ff4f3c
user: Christian Heimes <christian at cheimes.de>
date: Fri Jul 26 14:52:26 2013 +0200
summary:
Fix possible NULL pointer dereferences in testcapi module
CID 1058280
CID 1058282
CID 1058284
files:
Modules/_testcapimodule.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -120,6 +120,10 @@
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 @@
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 @@
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);
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list