summaryrefslogtreecommitdiffstats
path: root/Objects/longobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/longobject.c')
-rw-r--r--Objects/longobject.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c
index 0df3b9a..1db4ca4 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -5879,7 +5879,10 @@ int___sizeof___impl(PyObject *self)
{
Py_ssize_t res;
- res = offsetof(PyLongObject, ob_digit) + Py_ABS(Py_SIZE(self))*sizeof(digit);
+ res = offsetof(PyLongObject, ob_digit)
+ /* using Py_MAX(..., 1) because we always allocate space for at least
+ one digit, even though the integer zero has a Py_SIZE of 0 */
+ + Py_MAX(Py_ABS(Py_SIZE(self)), 1)*sizeof(digit);
return res;
}