Skip to content

Commit

Permalink
container/patricia: mowgli_patricia_elem_find(): avoid potential UB
Browse files Browse the repository at this point in the history
Identified by Clang v9 UBSAN (-fsanitize=undefined):

    patricia.c:671:17: runtime error: member access within null
                       pointer of type 'union patricia_elem'
  • Loading branch information
aaronmdjones committed Mar 24, 2019
1 parent ebbc4a7 commit 327b622
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/libmowgli/container/patricia.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,9 @@ mowgli_patricia_elem_find(mowgli_patricia_t *dict, const char *key)
if (ckey_buf != NULL)
mowgli_free(ckey_buf);

if (delem == NULL)
return NULL;

return &delem->leaf;
}

Expand Down

0 comments on commit 327b622

Please sign in to comment.