From: Hauke Mehrtens Date: Sun, 4 Oct 2020 15:14:50 +0000 (+0200) Subject: ucimap: Check return of malloc() X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=3fbd6c923434db61267e1331319b5b125e7838d8;p=project%2Fuci.git ucimap: Check return of malloc() Check the return value of malloc() before accessing it. Signed-off-by: Hauke Mehrtens --- diff --git a/ucimap.c b/ucimap.c index 7c2b043..c46cf45 100644 --- a/ucimap.c +++ b/ucimap.c @@ -893,14 +893,16 @@ ucimap_parse(struct uci_map *map, struct uci_package *pkg) if (sm->alloc) { sd = sm->alloc(map, sm, s); + if (!sd) + continue; memset(sd, 0, sizeof(struct ucimap_section_data)); } else { sd = malloc(sm->alloc_len); + if (!sd) + continue; memset(sd, 0, sm->alloc_len); sd = ucimap_ptr_section(sm, sd); } - if (!sd) - continue; ucimap_parse_section(map, sm, sd, s); }