Commit 48aa4b15 authored by Christian Heimes's avatar Christian Heimes

Get the ref counting for static allocated longs right.

parent cd5da7d5
...@@ -3714,17 +3714,15 @@ _PyLong_Init(void) ...@@ -3714,17 +3714,15 @@ _PyLong_Init(void)
/* The element is already initialized, most likely /* The element is already initialized, most likely
* the Python interpreter was initialized before. * the Python interpreter was initialized before.
*/ */
/* _Py_NewReference((PyObject*)v); Py_ssize_t refcnt;
* XXX: It sets the ref count to 1 but it may be
* larger. Emulate new reference w/o setting refcnt
* to 1.
*/
PyObject* op = (PyObject*)v; PyObject* op = (PyObject*)v;
_Py_INC_REFTOTAL;
op->ob_refcnt = (op->ob_refcnt < 1) ? 1 : op->ob_refcnt;
_Py_AddToAllObjects(op, 1);
_Py_INC_TPALLOCS(op);
refcnt = Py_REFCNT(op) < 0 ? 0 : Py_REFCNT(op);
_Py_NewReference(op);
/* _Py_NewReference sets the ref count to 1 but
* the ref count might be larger. Set the refcnt
* to the original refcnt + 1 */
Py_REFCNT(op) = refcnt + 1;
assert(Py_SIZE(op) == size); assert(Py_SIZE(op) == size);
assert(v->ob_digit[0] == abs(ival)); assert(v->ob_digit[0] == abs(ival));
} }
......
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