Repository navigation
Conversation
Check for integer overflow in PyObject_GC_Resize() and _PyObject_GC_NewVar(). Add _PyObject_GC_VAR_SIZE() which is similar to _PyObject_VAR_SIZE() but checks for integer overflow. Remove redundant (and incomplete) integer overflow from tuple_alloc() and _PyTuple_Resize().
|
It makes me grumpy that _PyObject_GC_NewVar() and _PyObject_GC_Resize() code is basically copied-pasted (with minor changes!) between Python/gc.c and Python/gc_free_threading.c. The problem is that gc_alloc() code is different and gc_alloc() is a private function. It's uneasy to share code between Python/gc.c and Python/gc_free_threading.c. I tried adding Python/gc_common.c, but I got stuck at gc_alloc(). I tried moving _PyObject_GC_VAR_SIZE() to Include/internal/pycore_gc.c, but _PyType_PreHeaderSize() is a static inline function declared in pycore_object.h which is not included by pycore_gc.h (and including pycore_object.h in pycore_gc.h would create a inter-dependency mess). So it seems like the best we can do for now is to copy/paste code :-( |
|
I searched for
Hum. A more generic approach would be to change |
|
I close this PR in favor of the more generic #161911. |
Check for integer overflow in PyObject_GC_Resize() and PyObject_GC_NewVar(). Add _PyObject_GC_VAR_SIZE() which is similar to _PyObject_VAR_SIZE() but checks for integer overflow.
Remove redundant (and incomplete) integer overflow from tuple_alloc() and _PyTuple_Resize().
PyTupleWriterAPI #161694