From dbd3aba5272012e16d66d6bc80a7cd653b8c8dbe Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Mon, 17 Feb 2020 17:55:29 -0800 Subject: [PATCH] Core: Fix crash modifying hash table entry (fixes #1673) --- CHANGES | 1 + src/util/table.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 3bae6140c..edabaf425 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,7 @@ 0.8.2: (Future) Other fixes: - Core: Fix ELF loading regression (fixes mgba.io/i/1669) + - Core: Fix crash modifying hash table entry (fixes mgba.io/i/1673) 0.8.1: (2020-02-16) Emulation fixes: diff --git a/src/util/table.c b/src/util/table.c index 20f4e159b..f4a85557f 100644 --- a/src/util/table.c +++ b/src/util/table.c @@ -187,7 +187,9 @@ void HashTableInsert(struct Table* table, const char* key, void* value) { struct TableList* list; TABLE_LOOKUP_START(HASH_TABLE_COMPARATOR, list, hash) { if (value != lookupResult->value) { - table->deinitializer(lookupResult->value); + if (table->deinitializer) { + table->deinitializer(lookupResult->value); + } lookupResult->value = value; } return;