Fix map bug: 'foo' and 'foobar' --> key collision

This commit is contained in:
olemorud
2023-04-25 05:01:28 +02:00
parent 7d24f2897f
commit edfea67b65

View File

@@ -90,10 +90,7 @@ bool obj_insert(obj_t m, char* const key, struct json_value* value)
/* traverse linked list to end or until key is found */ /* traverse linked list to end or until key is found */
while (cur != NULL) { while (cur != NULL) {
if (cur->key == NULL) if (strcmp(cur->key, key) == 0)
err(EXIT_FAILURE, "entry without key");
if (strncmp(cur->key, key, strlen(key)) == 0)
break; break;
cur = cur->next; cur = cur->next;