Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Sep 2011 21:28:26 +0000 (UTC)
From:      Christian Brueffer <brueffer@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r225370 - stable/7/bin/ed
Message-ID:  <201109032128.p83LSQqG062537@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: brueffer
Date: Sat Sep  3 21:28:26 2011
New Revision: 225370
URL: http://svn.freebsd.org/changeset/base/225370

Log:
  MFC: r225215
  
  Fix memory leak in error cases.

Modified:
  stable/7/bin/ed/buf.c
Directory Properties:
  stable/7/bin/ed/   (props changed)

Modified: stable/7/bin/ed/buf.c
==============================================================================
--- stable/7/bin/ed/buf.c	Sat Sep  3 20:46:30 2011	(r225369)
+++ stable/7/bin/ed/buf.c	Sat Sep  3 21:28:26 2011	(r225370)
@@ -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?201109032128.p83LSQqG062537>