forked from espressif/esp-idf
Merge branch 'bugfix/fix_write_to_null_pointer_if_malloc_failed_issue_v4.4' into 'release/v4.4'
Bugfix/fix write to null pointer if malloc failed issue(Backport v4.4) See merge request espressif/esp-idf!19352
This commit is contained in:
@@ -318,13 +318,13 @@ static esp_err_t example_espnow_init(void)
|
|||||||
|
|
||||||
/* Initialize sending parameters. */
|
/* Initialize sending parameters. */
|
||||||
send_param = malloc(sizeof(example_espnow_send_param_t));
|
send_param = malloc(sizeof(example_espnow_send_param_t));
|
||||||
memset(send_param, 0, sizeof(example_espnow_send_param_t));
|
|
||||||
if (send_param == NULL) {
|
if (send_param == NULL) {
|
||||||
ESP_LOGE(TAG, "Malloc send parameter fail");
|
ESP_LOGE(TAG, "Malloc send parameter fail");
|
||||||
vSemaphoreDelete(s_example_espnow_queue);
|
vSemaphoreDelete(s_example_espnow_queue);
|
||||||
esp_now_deinit();
|
esp_now_deinit();
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
memset(send_param, 0, sizeof(example_espnow_send_param_t));
|
||||||
send_param->unicast = false;
|
send_param->unicast = false;
|
||||||
send_param->broadcast = true;
|
send_param->broadcast = true;
|
||||||
send_param->state = 0;
|
send_param->state = 0;
|
||||||
|
@@ -144,11 +144,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;
|
||||||
|
Reference in New Issue
Block a user