summaryrefslogtreecommitdiff
path: root/fstree.c
diff options
context:
space:
mode:
authorJon Loeliger <jdl@jdl.com>2008-10-03 11:12:33 -0500
committerJon Loeliger <jdl@jdl.com>2008-10-03 11:12:33 -0500
commit879e4d2590b50d63f82c3c3652bc3c7900591f1c (patch)
tree360150a0a9f7b94f455ace32fc5145898d4c4b2f /fstree.c
parent68f98d7b8aa41fab175daf9f1bcb2a5bc22dbc90 (diff)
downloaddtc-879e4d2590b50d63f82c3c3652bc3c7900591f1c.tar.gz
Implement and use an xstrdup() function
Many places in dtc use strdup(), but none of them actually check the return value to see if the implied allocation succeeded. This is a potential bug, which we fix in the patch below by replacing strdup() with an xstrdup() which in analogy to xmalloc() will quit with a fatal error if the allocation fails. I felt the introduciton of util.[ch] was a better choice for utility oriented code than directly using srcpos.c for the new string function. This patch is a re-factoring of Dave Gibson's similar patch. Signed-off-by: Jon Loeliger <jdl@freescale.com>
Diffstat (limited to 'fstree.c')
-rw-r--r--fstree.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/fstree.c b/fstree.c
index 766b269..7aee982 100644
--- a/fstree.c
+++ b/fstree.c
@@ -58,7 +58,7 @@ static struct node *read_fstree(const char *dirname)
"WARNING: Cannot open %s: %s\n",
tmpnam, strerror(errno));
} else {
- prop = build_property(strdup(de->d_name),
+ prop = build_property(xstrdup(de->d_name),
data_copy_file(pfile,
st.st_size),
NULL);
@@ -69,7 +69,7 @@ static struct node *read_fstree(const char *dirname)
struct node *newchild;
newchild = read_fstree(tmpnam);
- newchild = name_node(newchild, strdup(de->d_name),
+ newchild = name_node(newchild, xstrdup(de->d_name),
NULL);
add_child(tree, newchild);
}