Skip to content

Commit

Permalink
修正了 del_env() 函数中的一处未判断 key 是否为 NULL 的 bug
Browse files Browse the repository at this point in the history
move_env() 中末尾处在调用 del_env() 时会使用 del_env(NULL, env, true),
此时 key 为 NULL, 需使用 old_env 中的 name 和 name_len
  • Loading branch information
wudicgi committed Dec 30, 2019
1 parent b91bd2c commit 9a3daaa
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions easyflash/src/ef_env.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
}

Expand Down

0 comments on commit 9a3daaa

Please sign in to comment.