Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 27 Aug 2011 15:28:57 +0000 (UTC)
From:      Christian Brueffer <brueffer@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r225215 - head/bin/ed
Message-ID:  <201108271528.p7RFSvGp011091@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: brueffer
Date: Sat Aug 27 15:28:57 2011
New Revision: 225215
URL: http://svn.freebsd.org/changeset/base/225215

Log:
  Fix memory leaks in error cases.
  
  PR:		159011
  Submitted by:	Henning Petersen <henning.petersen@t-online.de>
  Approved by:	re (kib)
  MFC after:	1 week

Modified:
  head/bin/ed/buf.c

Modified: head/bin/ed/buf.c
==============================================================================
--- head/bin/ed/buf.c	Sat Aug 27 14:24:27 2011	(r225214)
+++ head/bin/ed/buf.c	Sat Aug 27 15:28:57 2011	(r225215)
@@ -94,6 +94,7 @@ put_sbuf_line(const char *cs)
 		;
 	if (s - cs >= LINECHARS) {
 		errmsg = "line too long";
+		free(lp);
 		return NULL;
 	}
 	len = s - cs;
@@ -102,6 +103,7 @@ put_sbuf_line(const char *cs)
 		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 @@ put_sbuf_line(const char *cs)
 		sfseek = -1;
 		fprintf(stderr, "%s\n", strerror(errno));
 		errmsg = "cannot write temp file";
+		free(lp);
 		return NULL;
 	}
 	lp->len = len;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201108271528.p7RFSvGp011091>