esp_event: fix possible malloc free issues found by static analyzer See merge request idf/esp-idf!5142