Skip to content

Commit

Permalink
dict BUGFIX use value length after resize
Browse files Browse the repository at this point in the history
... because we are again comparing a possibly
unterminated string.
Refs #1045
  • Loading branch information
michalvasko committed Apr 3, 2020
1 parent d6c2aee commit b9a008a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/hash_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ lydict_remove(struct ly_ctx *ctx, const char *value)
}

static int
lydict_resize_val_eq(void *val1_p, void *val2_p, int UNUSED(mod), void *UNUSED(cb_data))
lydict_resize_val_eq(void *val1_p, void *val2_p, int mod, void *cb_data)
{
if (!val1_p || !val2_p) {
LOGARG;
Expand All @@ -207,8 +207,14 @@ lydict_resize_val_eq(void *val1_p, void *val2_p, int UNUSED(mod), void *UNUSED(c
return 0;
}

if (strcmp(str1, str2) == 0) {
return 1;
if (mod) {
/* used when inserting new values */
if (strcmp(str1, str2) == 0) {
return 1;
}
} else {
/* used when finding the original value again in the resized table */
return lydict_val_eq(val1_p, val2_p, mod, cb_data);
}

return 0;
Expand Down

0 comments on commit b9a008a

Please sign in to comment.