Skip to content

Commit

Permalink
Update idhash.c (nanomsg#1638)
Browse files Browse the repository at this point in the history
Fix for UBSAN error. As `id_reg_map` is initialised as NULL and passing NULL to `memcpy()` is undefined. Should make no difference to compiled code. Purely to appease the automated checks I have to deal with on my side. Thanks!
  • Loading branch information
shikokuchuo authored Feb 5, 2023
1 parent 539e559 commit e7a3e41
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/idhash.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ id_map_register(nni_id_map *m)
return (NNG_ENOMEM);
}
id_reg_len = len;
memcpy(mr, id_reg_map, id_reg_num * sizeof(nni_id_map *));
if (id_reg_map != NULL)
memcpy(mr, id_reg_map, id_reg_num * sizeof(nni_id_map *));
id_reg_map = mr;
}
id_reg_map[id_reg_num++] = m;
Expand Down

0 comments on commit e7a3e41

Please sign in to comment.