diff options
Diffstat (limited to 'Python')
-rw-r--r-- | Python/gc.c | 5 | ||||
-rw-r--r-- | Python/gc_free_threading.c | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/Python/gc.c b/Python/gc.c index 68879b9..7faf368 100644 --- a/Python/gc.c +++ b/Python/gc.c @@ -2310,11 +2310,12 @@ PyObject * PyUnstable_Object_GC_NewWithExtraData(PyTypeObject *tp, size_t extra_size) { size_t presize = _PyType_PreHeaderSize(tp); - PyObject *op = gc_alloc(tp, _PyObject_SIZE(tp) + extra_size, presize); + size_t size = _PyObject_SIZE(tp) + extra_size; + PyObject *op = gc_alloc(tp, size, presize); if (op == NULL) { return NULL; } - memset(op, 0, _PyObject_SIZE(tp) + extra_size); + memset((char *)op + sizeof(PyObject), 0, size - sizeof(PyObject)); _PyObject_Init(op, tp); return op; } diff --git a/Python/gc_free_threading.c b/Python/gc_free_threading.c index 0d6fddb..694f97d 100644 --- a/Python/gc_free_threading.c +++ b/Python/gc_free_threading.c @@ -2595,11 +2595,12 @@ PyObject * PyUnstable_Object_GC_NewWithExtraData(PyTypeObject *tp, size_t extra_size) { size_t presize = _PyType_PreHeaderSize(tp); - PyObject *op = gc_alloc(tp, _PyObject_SIZE(tp) + extra_size, presize); + size_t size = _PyObject_SIZE(tp) + extra_size; + PyObject *op = gc_alloc(tp, size, presize); if (op == NULL) { return NULL; } - memset(op, 0, _PyObject_SIZE(tp) + extra_size); + memset((char *)op + sizeof(PyObject), 0, size - sizeof(PyObject)); _PyObject_Init(op, tp); return op; } |