Commit f6433c13 authored by Sebastian Berg's avatar Sebastian Berg Committed by Stefan Behnel

BUG: Fix reference count issues (GH-3022)

parent b394295b
......@@ -432,8 +432,11 @@ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
PyMappingMethods *mm = Py_TYPE(o)->tp_as_mapping;
PySequenceMethods *sm = Py_TYPE(o)->tp_as_sequence;
if (mm && mm->mp_subscript) {
PyObject *key = PyInt_FromSsize_t(i);
return likely(key) ? mm->mp_subscript(o, key) : NULL;
PyObject *r, *key = PyInt_FromSsize_t(i);
if (unlikely(!key)) return NULL;
r = mm->mp_subscript(o, key);
Py_DECREF(key);
return r;
}
if (likely(sm && sm->sq_item)) {
if (wraparound && unlikely(i < 0) && likely(sm->sq_length)) {
......@@ -497,8 +500,12 @@ static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObje
PyMappingMethods *mm = Py_TYPE(o)->tp_as_mapping;
PySequenceMethods *sm = Py_TYPE(o)->tp_as_sequence;
if (mm && mm->mp_ass_subscript) {
int r;
PyObject *key = PyInt_FromSsize_t(i);
return likely(key) ? mm->mp_ass_subscript(o, key, v) : -1;
if (unlikely(!key)) return -1;
mm->mp_ass_subscript(o, key, v);
Py_DECREF(key);
return r;
}
if (likely(sm && sm->sq_ass_item)) {
if (wraparound && unlikely(i < 0) && likely(sm->sq_length)) {
......
......@@ -685,9 +685,11 @@ static PyObject* __Pyx__PyNumber_PowerOf2(PyObject *two, PyObject *exp, PyObject
return PyLong_FromUnsignedLongLong(value);
#endif
} else {
PyObject *one = PyInt_FromLong(1L);
PyObject *result, *one = PyInt_FromLong(1L);
if (unlikely(!one)) return NULL;
return PyNumber_Lshift(one, exp);
result = PyNumber_Lshift(one, exp);
Py_DECREF(one);
return result;
}
} else if (shiftby == -1 && PyErr_Occurred()) {
PyErr_Clear();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment