Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/dd Fix memory leak noted by Hubert Feyrer in private email.
details: https://anonhg.NetBSD.org/src/rev/129547169cd1
branches: trunk
changeset: 550760:129547169cd1
user: jschauma <jschauma%NetBSD.org@localhost>
date: Wed Aug 20 14:25:54 2003 +0000
description:
Fix memory leak noted by Hubert Feyrer in private email.
Patch by Hubert Feyrer as well, OK by kleink.
(I'm just fixing it b/c it's my fault to begin with.)
diffstat:
bin/dd/dd.c | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)
diffs (56 lines):
diff -r 617bb1a2e355 -r 129547169cd1 bin/dd/dd.c
--- a/bin/dd/dd.c Wed Aug 20 14:11:17 2003 +0000
+++ b/bin/dd/dd.c Wed Aug 20 14:25:54 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dd.c,v 1.31 2003/08/07 09:05:10 agc Exp $ */
+/* $NetBSD: dd.c,v 1.32 2003/08/20 14:25:54 jschauma Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -43,7 +43,7 @@
#if 0
static char sccsid[] = "@(#)dd.c 8.5 (Berkeley) 4/2/94";
#else
-__RCSID("$NetBSD: dd.c,v 1.31 2003/08/07 09:05:10 agc Exp $");
+__RCSID("$NetBSD: dd.c,v 1.32 2003/08/20 14:25:54 jschauma Exp $");
#endif
#endif /* not lint */
@@ -305,6 +305,12 @@
lseek(in.fd, (off_t)in.dbsz, SEEK_CUR))
warn("%s", fn);
+ /*
+ * Free memory from printescaped() before possible
+ * continue
+ */
+ free(fn);
+
/* If sync not specified, omit block and continue. */
if (!(ddflags & C_SYNC))
continue;
@@ -313,8 +319,6 @@
in.dbcnt += in.dbrcnt = in.dbsz;
++st.in_full;
- free(fn);
-
/* Handle full input blocks. */
} else if (n == in.dbsz) {
in.dbcnt += in.dbrcnt = n;
@@ -440,11 +444,14 @@
++st.out_part;
else
++st.out_full;
+ free(fn);
break;
}
++st.out_part;
- if (nw == cnt)
+ if (nw == cnt) {
+ free(fn);
break;
+ }
if (out.flags & ISCHR && !warned) {
warned = 1;
warnx("%s: short write on character device", fn);
Home |
Main Index |
Thread Index |
Old Index