summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/gcmodule.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
index 30b6839..43a7bf1 100644
--- a/Modules/gcmodule.c
+++ b/Modules/gcmodule.c
@@ -802,8 +802,9 @@ _PyObject_GC_Malloc(PyTypeObject *tp, int size)
{
PyObject *op;
#ifdef WITH_CYCLE_GC
- PyGC_Head *g = PyObject_MALLOC(_PyObject_VAR_SIZE(tp, size) +
- sizeof(PyGC_Head));
+ const size_t nbytes = sizeof(PyGC_Head) +
+ (size_t)_PyObject_VAR_SIZE(tp, size);
+ PyGC_Head *g = PyObject_MALLOC(nbytes);
if (g == NULL)
return (PyObject *)PyErr_NoMemory();
g->gc_next = NULL;