discover/grub2: Use script_env_set when initialising the environment
[petitboot] / discover / grub2 / script.c
index aeb59783e1b48c38d8b7aa9ed5fdf0f90c9bd7c8..c4f58d92bacb27395647a23d9c4f9feb5d8d6016 100644 (file)
@@ -432,13 +432,9 @@ static void init_env(struct grub2_script *script)
                                        sep - script->filename);
        }
 
-       env->name = talloc_strdup(env, "prefix");
+       script_env_set(script, "prefix", prefix ? : default_prefix);
        if (prefix)
-               env->value = prefix;
-       else
-               env->value = talloc_strdup(env, default_prefix);
-
-       list_add(&script->environment, &env->list);
+               talloc_free(prefix);
 }
 
 void script_register_function(struct grub2_script *script,