mdns: check all mallocs for failure and add default hook to log error with free heap

solves crash about _mdns_result_txt_create when stress test


* Original commit: espressif/esp-idf@c8cb4cd3c8
This commit is contained in:
David Cermak
2018-12-07 20:43:13 +01:00
committed by suren-gabrielyan-espressif
parent b4e57424f9
commit 7a4fdad16d
3 changed files with 66 additions and 0 deletions

View File

@ -5,6 +5,7 @@
*/
#include <string.h>
#include "mdns_networking.h"
#include "esp_log.h"
extern mdns_server_t * _mdns_server;
@ -13,6 +14,7 @@ extern mdns_server_t * _mdns_server;
* MDNS Server Networking
*
*/
static const char *TAG = "MDNS_Networking";
static struct udp_pcb * _pcb_main = NULL;
@ -118,6 +120,7 @@ static void _udp_recv(void *arg, struct udp_pcb *upcb, struct pbuf *pb, const ip
mdns_rx_packet_t * packet = (mdns_rx_packet_t *)malloc(sizeof(mdns_rx_packet_t));
if (!packet) {
HOOK_MALLOC_FAILED;
//missed packet - no memory
pbuf_free(this_pb);
continue;