Skip to content

Commit c9bdf4b

Browse files
fix for default build
1 parent 6b55b9d commit c9bdf4b

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

Python/typecache.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ static void free_cache_delayed(struct type_cache *cache)
5050
if (cache == NULL || cache == &empty_cache) {
5151
return;
5252
}
53+
#ifndef Py_GIL_DISABLED
54+
for (uint32_t i = 0; i < cache_size(cache); i++) {
55+
if (cache->hashtable[i].name != NULL) {
56+
Py_DECREF(cache->hashtable[i].name);
57+
}
58+
}
59+
#endif
5360
_PyMem_FreeDelayed(cache, cache_nbytes(cache));
5461
}
5562

@@ -88,6 +95,7 @@ static inline void type_cache_insert(struct type_cache *cache, PyObject *name,
8895
uint32_t index = hash & cache->mask;
8996
for (;;) {
9097
if (cache->hashtable[index].name == NULL) {
98+
Py_INCREF(name);
9199
FT_ATOMIC_STORE_PTR(cache->hashtable[index].value, value);
92100
FT_ATOMIC_STORE_PTR(cache->hashtable[index].name, name);
93101
cache->used++;

0 commit comments

Comments
 (0)