diff options
author | Jon Loeliger <jdl@jdl.com> | 2008-10-03 11:12:33 -0500 |
---|---|---|
committer | Jon Loeliger <jdl@jdl.com> | 2008-10-03 11:12:33 -0500 |
commit | 879e4d2590b50d63f82c3c3652bc3c7900591f1c (patch) | |
tree | 360150a0a9f7b94f455ace32fc5145898d4c4b2f /convert-dtsv0-lexer.l | |
parent | 68f98d7b8aa41fab175daf9f1bcb2a5bc22dbc90 (diff) | |
download | dtc-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 'convert-dtsv0-lexer.l')
-rw-r--r-- | convert-dtsv0-lexer.l | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/convert-dtsv0-lexer.l b/convert-dtsv0-lexer.l index 12b45ea..194f635 100644 --- a/convert-dtsv0-lexer.l +++ b/convert-dtsv0-lexer.l @@ -42,6 +42,7 @@ GAP ({WS}|{COMMENT}|{LINECOMMENT})* #include <fnmatch.h> #include "srcpos.h" +#include "util.h" static int v1_tagged; /* = 0 */ static int cbase = 16; @@ -185,7 +186,7 @@ const struct { <PROPNODENAME>{PROPNODECHAR}+ { ECHO; - last_name = strdup(yytext); + last_name = xstrdup(yytext); BEGIN(INITIAL); } |