Преглед изворни кода

fix possible memory leak if report level not set

Oleg Savchenko пре 3 година
родитељ
комит
656d6dac15
1 измењених фајлова са 2 додато и 1 уклоњено
  1. 2 1
      examples/wifi/ftm/main/ftm_main.c

+ 2 - 1
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)
 static void ftm_process_report(void)
 {
 {
     int i;
     int i;
-    char *log = malloc(200);
+    char *log = NULL;
 
 
     if (!g_report_lvl)
     if (!g_report_lvl)
         return;
         return;
 
 
+    log = malloc(200);
     if (!log) {
     if (!log) {
         ESP_LOGE(TAG_STA, "Failed to alloc buffer for FTM report");
         ESP_LOGE(TAG_STA, "Failed to alloc buffer for FTM report");
         return;
         return;