Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/gpt CID 1341563: fix leak
details: https://anonhg.NetBSD.org/src/rev/f868dae8e6b0
branches: trunk
changeset: 342047:f868dae8e6b0
user: christos <christos%NetBSD.org@localhost>
date: Thu Dec 03 21:48:12 2015 +0000
description:
CID 1341563: fix leak
diffstat:
sbin/gpt/label.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diffs (40 lines):
diff -r 7d8055e4d79e -r f868dae8e6b0 sbin/gpt/label.c
--- a/sbin/gpt/label.c Thu Dec 03 21:46:22 2015 +0000
+++ b/sbin/gpt/label.c Thu Dec 03 21:48:12 2015 +0000
@@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/label.c,v 1.3 2006/10/04 18:20:25 marcel Exp $");
#endif
#ifdef __RCSID
-__RCSID("$NetBSD: label.c,v 1.25 2015/12/03 01:07:28 christos Exp $");
+__RCSID("$NetBSD: label.c,v 1.26 2015/12/03 21:48:12 christos Exp $");
#endif
#include <sys/types.h>
@@ -98,13 +98,12 @@
if ((*name = malloc(maxlen)) == NULL) {
gpt_warn(gpt, "Can't copy string");
- return -1;
+ goto cleanup;
}
len = fread(*name, 1, maxlen - 1, f);
if (ferror(f)) {
- free(*name);
gpt_warn(gpt, "Can't label from `%s'", fn);
- return -1;
+ goto cleanup;
}
if (f != stdin)
fclose(f);
@@ -114,6 +113,11 @@
if (p != NULL)
*p = '\0';
return 0;
+cleanup:
+ free(*name);
+ if (f != stdin)
+ fclose(f);
+ return -1;
}
static int
Home |
Main Index |
Thread Index |
Old Index