summaryrefslogtreecommitdiffstats
path: root/text-utils/display.c
diff options
context:
space:
mode:
authorOndrej Oprala2013-09-23 15:39:38 +0200
committerKarel Zak2013-11-08 14:16:29 +0100
commitd2740b0ef6c8b7785f575432fb3ae78cdae8f89e (patch)
treec65ba7029a49d819911ceedb0e15d258e4a1d71a /text-utils/display.c
parenthexdump: make addfile() variable names more hinting of their purpose (diff)
downloadkernel-qcow2-util-linux-d2740b0ef6c8b7785f575432fb3ae78cdae8f89e.tar.gz
kernel-qcow2-util-linux-d2740b0ef6c8b7785f575432fb3ae78cdae8f89e.tar.xz
kernel-qcow2-util-linux-d2740b0ef6c8b7785f575432fb3ae78cdae8f89e.zip
hexdump: catch memory leaks
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Diffstat (limited to 'text-utils/display.c')
-rw-r--r--text-utils/display.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/text-utils/display.c b/text-utils/display.c
index 0782c9c12..b6b1f140d 100644
--- a/text-utils/display.c
+++ b/text-utils/display.c
@@ -279,12 +279,12 @@ get(void)
*/
if (!length || (ateof && !next(NULL))) {
if (need == blocksize)
- return(NULL);
+ goto retnul;
if (!need && vflag != ALL &&
!memcmp(curp, savp, nread)) {
if (vflag != DUP)
printf("*\n");
- return(NULL);
+ goto retnul;
}
if (need > 0)
memset((char *)curp + nread, 0, need);
@@ -293,7 +293,7 @@ get(void)
}
if (fileno(stdin) == -1) {
warnx(_("all input file arguments failed"));
- return(NULL);
+ goto retnul;
}
n = fread((char *)curp + nread, sizeof(unsigned char),
length == -1 ? need : min(length, need), stdin);
@@ -323,6 +323,10 @@ get(void)
else
nread += n;
}
+retnul:
+ free (curp);
+ free (savp);
+ return NULL;
}
int next(char **argv)