summaryrefslogtreecommitdiff
path: root/fstree.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2023-02-27 23:11:29 +1100
committerDavid Gibson <david@gibson.dropbear.id.au>2023-03-01 17:47:27 +1100
commit0b842c3c819971cdbe0915469759c40f6eb3db7e (patch)
tree98fcb46e669e220cce63b42db3f21a6ac170bfd6 /fstree.c
parent9cceabea1ee09ae0864d365b7b3cc89a01b1287c (diff)
downloaddevice-tree-compiler-0b842c3c819971cdbe0915469759c40f6eb3db7e.tar.gz
Make build_property() xstrdup its name argument
The name field of 'struct property' was really always supposed to be a malloc()ed string, that is owned by the structure. To avoid an extra strdup() for strings coming up from the lexer, build_property() and build_property_delete() expect to take such an already malloc()ed string, which means it's not correct to pass it a static string literal. That's a pretty non-obvious constraint, so a bunch of incorrect uses have crept in. Really, avoiding the extra dup from the lexer isn't a big enough benefit for this demonstrably dangerous interface. So change it to do the xstrdup() itself, removing the burden from callers. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'fstree.c')
-rw-r--r--fstree.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fstree.c b/fstree.c
index 5e59594..0f9a534 100644
--- a/fstree.c
+++ b/fstree.c
@@ -43,7 +43,7 @@ static struct node *read_fstree(const char *dirname)
"WARNING: Cannot open %s: %s\n",
tmpname, strerror(errno));
} else {
- prop = build_property(xstrdup(de->d_name),
+ prop = build_property(de->d_name,
data_copy_file(pfile,
st.st_size),
NULL);