]> git.ozlabs.org Git - petitboot/blobdiff - discover/grub2/script.c
discover/grub2: strdup strings used in the environment
[petitboot] / discover / grub2 / script.c
index 75b8aaaae474fc6348215dea26d7e963f31e4562..2aaf1d3d2cb1495a63c48fe7d31f72882d921b52 100644 (file)
@@ -23,8 +23,8 @@
        container_of(stmt, struct grub2_statement_conditional, st)
 
 struct env_entry {
-       const char              *name;
-       const char              *value;
+       char                    *name;
+       char                    *value;
        struct list_item        list;
 };
 
@@ -75,11 +75,13 @@ void script_env_set(struct grub2_script *script,
 
        if (!entry) {
                entry = talloc(script, struct env_entry);
-               entry->name = name;
+               entry->name = talloc_strdup(entry, name);
                list_add(&script->environment, &entry->list);
+       } else {
+               talloc_free(entry->value);
        }
 
-       entry->value = value;
+       entry->value = talloc_strdup(entry, value);
 }
 
 static bool expand_var(struct grub2_script *script, struct grub2_word *word)