File tree Expand file tree Collapse file tree
Misc/NEWS.d/next/Core_and_Builtins Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ Fixes possible crash on :class: `types.CodeType ` deallocation.
Original file line number Diff line number Diff line change @@ -743,6 +743,10 @@ _PyCode_New(struct _PyCodeConstructor *con)
743743 return NULL ;
744744 }
745745
746+ #ifdef Py_GIL_DISABLED
747+ co -> _co_unique_id = _Py_INVALID_UNIQUE_ID ;
748+ #endif
749+
746750 if (init_code (co , con ) < 0 ) {
747751 Py_DECREF (co );
748752 return NULL ;
@@ -2449,15 +2453,17 @@ code_dealloc(PyObject *self)
24492453 FT_CLEAR_WEAKREFS (self , co -> co_weakreflist );
24502454 free_monitoring_data (co -> _co_monitoring );
24512455#ifdef Py_GIL_DISABLED
2452- // The first element always points to the mutable bytecode at the end of
2453- // the code object, which will be freed when the code object is freed.
2454- for (Py_ssize_t i = 1 ; i < co -> co_tlbc -> size ; i ++ ) {
2455- char * entry = co -> co_tlbc -> entries [i ];
2456- if (entry != NULL ) {
2457- PyMem_Free (entry );
2456+ if (co -> co_tlbc != NULL ) {
2457+ // The first element always points to the mutable bytecode at the end of
2458+ // the code object, which will be freed when the code object is freed.
2459+ for (Py_ssize_t i = 1 ; i < co -> co_tlbc -> size ; i ++ ) {
2460+ char * entry = co -> co_tlbc -> entries [i ];
2461+ if (entry != NULL ) {
2462+ PyMem_Free (entry );
2463+ }
24582464 }
2465+ PyMem_Free (co -> co_tlbc );
24592466 }
2460- PyMem_Free (co -> co_tlbc );
24612467#endif
24622468 PyObject_Free (co );
24632469}
You can’t perform that action at this time.
0 commit comments