all repos — mgba @ a9e0935af8815099b51c1b0933aacf1aa4ce8687

mGBA Game Boy Advance Emulator

Util: Ensure key sizes match before comparing
Vicki Pfau vi@endrift.com
Mon, 17 Aug 2020 01:10:02 -0700
commit

a9e0935af8815099b51c1b0933aacf1aa4ce8687

parent

343812e9e6b1d3979121a89e6f58b8908f9c2cdf

1 files changed, 1 insertions(+), 1 deletions(-)

jump to
M src/util/table.csrc/util/table.c

@@ -14,7 +14,7 @@ #define TABLE_INITIAL_SIZE 8

#define TABLE_COMPARATOR(LIST, INDEX) LIST->list[(INDEX)].key == key #define HASH_TABLE_STRNCMP_COMPARATOR(LIST, INDEX) LIST->list[(INDEX)].key == hash && strncmp(LIST->list[(INDEX)].stringKey, key, LIST->list[(INDEX)].keylen) == 0 -#define HASH_TABLE_MEMCMP_COMPARATOR(LIST, INDEX) LIST->list[(INDEX)].key == hash && memcmp(LIST->list[(INDEX)].stringKey, key, LIST->list[(INDEX)].keylen) == 0 +#define HASH_TABLE_MEMCMP_COMPARATOR(LIST, INDEX) LIST->list[(INDEX)].key == hash && LIST->list[(INDEX)].keylen == keylen && memcmp(LIST->list[(INDEX)].stringKey, key, LIST->list[(INDEX)].keylen) == 0 #define TABLE_LOOKUP_START(COMPARATOR, LIST) \ size_t i; \