shared/shell: Don't allocate any data if env value is NULL
If value is NULL there is no point in allocating any data if value is
NULL since bt_shell_get_env would return NULL anyway, also this makes
sure the existing value is freed which means passing NULL can remove
an env like it was intended.
diff --git a/src/shared/shell.c b/src/shared/shell.c
index b503c66..367e255 100644
--- a/src/shared/shell.c
+++ b/src/shared/shell.c
@@ -1145,6 +1145,8 @@
struct bt_shell_env *env;
if (!data.envs) {
+ if (!value)
+ return;
data.envs = queue_new();
goto done;
}
@@ -1153,6 +1155,10 @@
if (env)
env_destroy(env);
+ /* Don't create an env if value is not set */
+ if (!value)
+ return;
+
done:
env = new0(struct bt_shell_env, 1);
env->name = strdup(name);