From dbda4b6fec6ff955053017bc285f981bde42a4c1 Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Fri, 4 Aug 2023 13:39:33 +0900 Subject: [PATCH] battery: Add check NULL derefernce Fix static analysis NULL dereferce issue. Change-Id: Ib33ce3df0eab04c62c9096d78e09ff2e093edd57 Signed-off-by: Yunhee Seo --- src/battery/battery-parser.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/battery/battery-parser.c b/src/battery/battery-parser.c index 91f8b50..e0370d5 100644 --- a/src/battery/battery-parser.c +++ b/src/battery/battery-parser.c @@ -97,6 +97,9 @@ static int parse_event_action(const struct parse_result *result, void *data) info->event_handlers = realloc(info->event_handlers, sizeof(struct battery_config_charger_event_handler*) * (info->event_handler_number + 1)); + if (!info->event_handlers) + return 0; + info->event_handlers[info->event_handler_number++] = handler; return 0; -- 2.7.4