Skip to content

Commit

Permalink
nostrdb: fix ndb_builder_find_str.
Browse files Browse the repository at this point in the history
This will find strings which match the beginning of other strings,
which seems wrong.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Aug 24, 2024
1 parent a0816e5 commit 413fca1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/nostrdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -5065,7 +5065,7 @@ static inline int ndb_builder_find_str(struct ndb_builder *builder,
uint32_t index = ((uint32_t*)builder->str_indices.start)[i];
const char *some_str = (const char*)builder->strings.start + index;

if (!memcmp(some_str, str, len)) {
if (!memcmp(some_str, str, len) && some_str[len] == '\0') {
// found an existing matching str, use that index
*pstr = ndb_offset_str(index);
return 1;
Expand Down

0 comments on commit 413fca1

Please sign in to comment.