if (h->py_alias != NULL) {
if (_Py_hashtable_set(ht, (const void*)entry->py_alias, (void*)entry) < 0) {
- PyMem_Free(entry);
+ /* entry is already in ht, will be freed by _Py_hashtable_destroy() */
goto error;
}
entry->refcnt++;
assert(value->display_name == NULL);
value->refcnt = 0;
-#define Py_HMAC_HINFO_LINK(KEY) \
- do { \
- int rc = py_hmac_hinfo_ht_add(table, KEY, value); \
- if (rc < 0) { \
- PyMem_Free(value); \
- goto error; \
- } \
- else if (rc == 1) { \
- value->refcnt++; \
- } \
+#define Py_HMAC_HINFO_LINK(KEY) \
+ do { \
+ int rc = py_hmac_hinfo_ht_add(table, (KEY), value); \
+ if (rc < 0) { \
+ /* entry may already be in ht, freed upon exit */ \
+ if (value->refcnt == 0) { \
+ PyMem_Free(value); \
+ } \
+ goto error; \
+ } \
+ else if (rc == 1) { \
+ value->refcnt++; \
+ } \
} while (0)
Py_HMAC_HINFO_LINK(e->name);
Py_HMAC_HINFO_LINK(e->hashlib_name);