From 9a16b551effa52c2035afabfb42e689ba364b389 Mon Sep 17 00:00:00 2001 From: kewal shah Date: Tue, 6 Oct 2020 10:10:32 +0530 Subject: [PATCH] protocomm_console.c: Check if memory is allocated to buf and if not then return ESP_ERR_NO_MEM error --- components/protocomm/src/transports/protocomm_console.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/protocomm/src/transports/protocomm_console.c b/components/protocomm/src/transports/protocomm_console.c index 9e0243be44..6bd6e02d4e 100644 --- a/components/protocomm/src/transports/protocomm_console.c +++ b/components/protocomm/src/transports/protocomm_console.c @@ -139,6 +139,10 @@ static int common_cmd_handler(int argc, char** argv) uint32_t cur_session_id = atoi(argv[1]); uint8_t *buf = (uint8_t *) malloc(strlen(argv[2])); + if (buf == NULL) { + ESP_LOGE(TAG, "Failed to allocate memory"); + return ESP_ERR_NO_MEM; + } uint8_t *outbuf; ssize_t outlen; ssize_t len = hex2bin(argv[2], buf);