Date: Mon, 18 Jul 2011 16:02:32 GMT From: Henning Petersen <henning.petersen@t-online.de> To: freebsd-gnats-submit@FreeBSD.org Subject: bin/159011: Memory leak in bin/ed/buf.c Message-ID: <201107181602.p6IG2WpB083842@red.freebsd.org> Resent-Message-ID: <201107181610.p6IGA99j017352@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 159011
>Category: bin
>Synopsis: Memory leak in bin/ed/buf.c
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Mon Jul 18 16:10:09 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator: Henning Petersen
>Release: FreeBSD-current
>Organization:
>Environment:
>Description:
Memory leak in bin/ed/buf.c .
>How-To-Repeat:
>Fix:
diff -u -r1.22 buf.c
--- bin/ed/buf.c 30 Jun 2002 05:13:53 -0000 1.22
+++ bin/ed/buf.c 18 Jul 2011 13:19:28 -0000
@@ -94,6 +94,7 @@
;
if (s - cs >= LINECHARS) {
errmsg = "line too long";
+ free(lp);
return NULL;
}
len = s - cs;
@@ -102,6 +103,7 @@
if (fseeko(sfp, (off_t)0, SEEK_END) < 0) {
fprintf(stderr, "%s\n", strerror(errno));
errmsg = "cannot seek temp file";
+ free(lp);
return NULL;
}
sfseek = ftello(sfp);
@@ -112,6 +114,7 @@
sfseek = -1;
fprintf(stderr, "%s\n", strerror(errno));
errmsg = "cannot write temp file";
+ free(lp);
return NULL;
}
lp->len = len;
Patch attached with submission follows:
diff -u -r1.22 buf.c
--- bin/ed/buf.c 30 Jun 2002 05:13:53 -0000 1.22
+++ bin/ed/buf.c 18 Jul 2011 13:19:28 -0000
@@ -94,6 +94,7 @@
;
if (s - cs >= LINECHARS) {
errmsg = "line too long";
+ free(lp);
return NULL;
}
len = s - cs;
@@ -102,6 +103,7 @@
if (fseeko(sfp, (off_t)0, SEEK_END) < 0) {
fprintf(stderr, "%s\n", strerror(errno));
errmsg = "cannot seek temp file";
+ free(lp);
return NULL;
}
sfseek = ftello(sfp);
@@ -112,6 +114,7 @@
sfseek = -1;
fprintf(stderr, "%s\n", strerror(errno));
errmsg = "cannot write temp file";
+ free(lp);
return NULL;
}
lp->len = len;
>Release-Note:
>Audit-Trail:
>Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201107181602.p6IG2WpB083842>
