Skip to content

Commit

Permalink
Add missing malloc NULL check and free
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz authored and tguillem committed Aug 21, 2019
1 parent e3cfec0 commit 6ae904f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/mdns.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,12 @@ mdns_list_interfaces(multicast_if** pp_intfs, size_t* p_nb_intf, int ai_family)
++nb_intf;
}
if (nb_intf == 0) {
*pp_intfs = malloc(sizeof(*intfs));
// Fallback to the default interface
*pp_intfs = malloc(sizeof(*intfs));
if (*pp_intfs == NULL) {
free(res);
return (MDNS_ERROR);
}
**pp_intfs = 0;
*p_nb_intf = 1;
return (0);
Expand Down Expand Up @@ -224,6 +228,7 @@ mdns_list_interfaces(multicast_if** pp_intfs, size_t* p_nb_intf, int ai_family)
++intfs;
}
*p_nb_intf = nb_intf;
free(res);
return (0);
}
#endif
Expand Down

0 comments on commit 6ae904f

Please sign in to comment.