From 50e00e641bcee524adae7524c1de68609195c0ab Mon Sep 17 00:00:00 2001 From: xiongweichao Date: Thu, 6 Jan 2022 19:54:02 +0800 Subject: [PATCH] fixed config parse crash after flash_erase Closes https://github.com/espressif/esp-idf/issues/6170 --- components/bt/common/osi/config.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/bt/common/osi/config.c b/components/bt/common/osi/config.c index b3b8816037..9e3dc89a3c 100644 --- a/components/bt/common/osi/config.c +++ b/components/bt/common/osi/config.c @@ -550,10 +550,12 @@ static void config_parse(nvs_handle_t fp, config_t *config) const size_t keyname_bufsz = sizeof(CONFIG_KEY) + 5 + 1; // including log10(sizeof(i)) char *keyname = osi_calloc(keyname_bufsz); int buf_size = get_config_size_from_flash(fp); - char *buf = osi_calloc(buf_size); + char *buf = NULL; + if(buf_size == 0) { //First use nvs goto error; } + buf = osi_calloc(buf_size); if (!line || !section || !buf || !keyname) { err_code |= 0x01; goto error;