summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Loder <cloder@cvs.openbsd.org>2005-06-03 15:18:06 +0000
committerChad Loder <cloder@cvs.openbsd.org>2005-06-03 15:18:06 +0000
commite78914d7cf14b7636b22bcc1fe4fd3c1dd2aa62e (patch)
tree87b57c2d05fe0ce1cdf151baf6148e4c8057af6f
parent2d27e91488c2a84af3958899f86ecb8e164e3633 (diff)
Fix memory leak. OK kjell, with comments by beck and kjell
-rw-r--r--usr.bin/mg/buffer.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/usr.bin/mg/buffer.c b/usr.bin/mg/buffer.c
index b5e4351b924..6791b98035d 100644
--- a/usr.bin/mg/buffer.c
+++ b/usr.bin/mg/buffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: buffer.c,v 1.41 2005/06/03 08:23:12 kjell Exp $ */
+/* $OpenBSD: buffer.c,v 1.42 2005/06/03 15:18:05 cloder Exp $ */
/*
* Buffer handling.
@@ -331,8 +331,8 @@ listbuf_goto_buffer_helper(int f, int n, int only)
{
BUFFER *bp;
MGWIN *wp;
- char *line;
- int i;
+ char *line = NULL;
+ int i, ret = FALSE;
if (curwp->w_dotp->l_text[listbuf_ncol/2 - 1] == '$') {
ewprintf("buffer name truncated");
@@ -350,24 +350,29 @@ listbuf_goto_buffer_helper(int f, int n, int only)
}
}
if (i == 0)
- return (FALSE);
+ goto cleanup;
for (bp = bheadp; bp != NULL; bp = bp->b_bufp) {
if (strcmp(bp->b_bname, line) == 0)
break;
}
if (bp == NULL)
- return (FALSE);
+ goto cleanup;
if ((wp = popbuf(bp)) == NULL)
- return (FALSE);
+ goto cleanup;
curbp = bp;
curwp = wp;
if (only)
- return (onlywind(f, n));
+ ret = (onlywind(f, n));
+ else
+ ret = TRUE;
- return (TRUE);
+cleanup:
+ free(line);
+
+ return (ret);
}
/*