Skip to content

Commit

Permalink
Fix memory leaks in error cases.
Browse files Browse the repository at this point in the history
PR:		159011
Submitted by:	Henning Petersen <henning.petersen@t-online.de>
Approved by:	re (kib)
MFC after:	1 week
  • Loading branch information
cbrueffer committed Aug 27, 2011
1 parent e5a0927 commit ae56847
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bin/ed/buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit ae56847

Please sign in to comment.