From 656d6dac15c980dabde7d20acca7ea7061476a23 Mon Sep 17 00:00:00 2001 From: Oleg Savchenko Date: Sun, 17 Jul 2022 11:24:12 +0300 Subject: [PATCH] fix possible memory leak if report level not set --- examples/wifi/ftm/main/ftm_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/wifi/ftm/main/ftm_main.c b/examples/wifi/ftm/main/ftm_main.c index db781b5a37..5fde04f410 100644 --- a/examples/wifi/ftm/main/ftm_main.c +++ b/examples/wifi/ftm/main/ftm_main.c @@ -145,11 +145,12 @@ static void event_handler(void *arg, esp_event_base_t event_base, static void ftm_process_report(void) { int i; - char *log = malloc(200); + char *log = NULL; if (!g_report_lvl) return; + log = malloc(200); if (!log) { ESP_LOGE(TAG_STA, "Failed to alloc buffer for FTM report"); return;