mirror of
https://github.com/python/cpython.git
synced 2025-11-03 19:34:08 +00:00
Fix possible NULL pointer dereferences in testcapi module
CID 1058280 CID 1058282 CID 1058284
This commit is contained in:
commit
5e3de55b01
1 changed files with 7 additions and 1 deletions
|
|
@ -120,6 +120,10 @@ test_dict_inner(int count)
|
||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
v = PyLong_FromLong(i);
|
v = PyLong_FromLong(i);
|
||||||
|
if (v == NULL) {
|
||||||
|
Py_DECREF(v);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (PyDict_SetItem(dict, v, v) < 0) {
|
if (PyDict_SetItem(dict, v, v) < 0) {
|
||||||
Py_DECREF(v);
|
Py_DECREF(v);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -1656,6 +1660,8 @@ test_long_numbits(PyObject *self)
|
||||||
|
|
||||||
for (i = 0; i < Py_ARRAY_LENGTH(testcases); ++i) {
|
for (i = 0; i < Py_ARRAY_LENGTH(testcases); ++i) {
|
||||||
PyObject *plong = PyLong_FromLong(testcases[i].input);
|
PyObject *plong = PyLong_FromLong(testcases[i].input);
|
||||||
|
if (plong == NULL)
|
||||||
|
return NULL;
|
||||||
size_t nbits = _PyLong_NumBits(plong);
|
size_t nbits = _PyLong_NumBits(plong);
|
||||||
int sign = _PyLong_Sign(plong);
|
int sign = _PyLong_Sign(plong);
|
||||||
|
|
||||||
|
|
@ -2248,7 +2254,7 @@ profile_int(PyObject *self, PyObject* args)
|
||||||
gettimeofday(&start, NULL);
|
gettimeofday(&start, NULL);
|
||||||
for(i=0; i < 10000000; i++) {
|
for(i=0; i < 10000000; i++) {
|
||||||
result = PyNumber_Add(op1, op1);
|
result = PyNumber_Add(op1, op1);
|
||||||
Py_DECREF(result);
|
Py_XDECREF(result);
|
||||||
}
|
}
|
||||||
gettimeofday(&stop, NULL);
|
gettimeofday(&stop, NULL);
|
||||||
Py_DECREF(op1);
|
Py_DECREF(op1);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue