summaryrefslogtreecommitdiffstats
path: root/text-utils/parse.c
diff options
context:
space:
mode:
authorKarel Zak2012-02-02 15:34:08 +0100
committerKarel Zak2012-02-02 15:34:08 +0100
commitbafd2d4653ebb9e49853ba8688d46fc8b3748df5 (patch)
tree76dab2107c007274161716baeded14aa5633fde7 /text-utils/parse.c
parentlib/loopdev: remove dead assigment and null deference (diff)
downloadkernel-qcow2-util-linux-bafd2d4653ebb9e49853ba8688d46fc8b3748df5.tar.gz
kernel-qcow2-util-linux-bafd2d4653ebb9e49853ba8688d46fc8b3748df5.tar.xz
kernel-qcow2-util-linux-bafd2d4653ebb9e49853ba8688d46fc8b3748df5.zip
hexdump: make code more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'text-utils/parse.c')
-rw-r--r--text-utils/parse.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/text-utils/parse.c b/text-utils/parse.c
index e41b4a0c7..481db6d3e 100644
--- a/text-utils/parse.c
+++ b/text-utils/parse.c
@@ -80,7 +80,7 @@ void addfile(char *name)
void add(const char *fmt)
{
const char *p;
- static FS **nextfs;
+ static FS **nextfs = NULL;
FS *tfs;
FU *tfu, **nextfu;
const char *savep;
@@ -89,8 +89,9 @@ void add(const char *fmt)
tfs = xcalloc(1, sizeof(FS));
if (!fshead)
fshead = tfs;
- else
+ else if (nextfs)
*nextfs = tfs;
+
nextfs = &tfs->nextfs;
nextfu = &tfs->nextfu;
@@ -222,7 +223,7 @@ void rewrite(FS *fs)
pr = xcalloc(1, sizeof(PR));
if (!fu->nextpr)
fu->nextpr = pr;
- else
+ else if (nextpr)
*nextpr = pr;
/* Skip preceding text and up to the next % sign. */