From 9a3daaa4c63ea3245e76daca8c44e0b6f7776314 Mon Sep 17 00:00:00 2001 From: Wudi Date: Mon, 30 Dec 2019 15:22:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=BA=86=20del=5Fenv()=20?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E4=B8=AD=E7=9A=84=E4=B8=80=E5=A4=84=E6=9C=AA?= =?UTF-8?q?=E5=88=A4=E6=96=AD=20key=20=E6=98=AF=E5=90=A6=E4=B8=BA=20NULL?= =?UTF-8?q?=20=E7=9A=84=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit move_env() 中末尾处在调用 del_env() 时会使用 del_env(NULL, env, true), 此时 key 为 NULL, 需使用 old_env 中的 name 和 name_len --- easyflash/src/ef_env.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/easyflash/src/ef_env.c b/easyflash/src/ef_env.c index ce78d2f..a8f65b2 100644 --- a/easyflash/src/ef_env.c +++ b/easyflash/src/ef_env.c @@ -1095,8 +1095,14 @@ static EfErrCode del_env(const char *key, env_node_obj_t old_env, bool complete_ if (!last_is_complete_del && result == EF_NO_ERR) { #ifdef EF_ENV_USING_CACHE - /* only delete the ENV in flash and cache when only using del_env(key, env, true) in ef_del_env() */ - update_env_cache(key, strlen(key), FAILED_ADDR); + /* delete the ENV in flash and cache */ + if (key != NULL) { + /* when using del_env(key, NULL, true) or del_env(key, env, true) in ef_del_env() and set_env() */ + update_env_cache(key, strlen(key), FAILED_ADDR); + } else if (old_env != NULL) { + /* when using del_env(NULL, env, true) in move_env() */ + update_env_cache(old_env->name, old_env->name_len, FAILED_ADDR); + } #endif /* EF_ENV_USING_CACHE */ }