Skip to content

Commit b5dbdd8

Browse files
authored
consider length of string keys (#308)
Prevent str_set comparison from accepting prefix as false positive
1 parent 4dfe2dc commit b5dbdd8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

external/hash/str_set.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ DEFINE_HASH_TABLE(str_set)
4747
*/
4848
static inline int ht_match(const void *key, size_t len, str_set_item_t item)
4949
{
50-
return strncmp(key, item, len) == 0;
50+
return strncmp(key, item, len) == 0 && item[len] == '\0';
5151
}
5252

5353
static inline const void *ht_key(str_set_item_t item)

0 commit comments

Comments
 (0)