Coverity CID 1668: Plug memory leak.

This commit is contained in:
christos 2006-03-18 09:31:36 +00:00
parent 58ad32062f
commit a46f31170d
1 changed files with 12 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: term.c,v 1.43 2006/03/18 09:02:08 christos Exp $ */
/* $NetBSD: term.c,v 1.44 2006/03/18 09:31:36 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)term.c 8.2 (Berkeley) 4/30/95";
#else
__RCSID("$NetBSD: term.c,v 1.43 2006/03/18 09:02:08 christos Exp $");
__RCSID("$NetBSD: term.c,v 1.44 2006/03/18 09:31:36 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@ -473,8 +473,12 @@ term_alloc_display(EditLine *el)
return (-1);
for (i = 0; i < c->v; i++) {
b[i] = (char *) el_malloc((size_t) (sizeof(char) * (c->h + 1)));
if (b[i] == NULL)
if (b[i] == NULL) {
while (--i >= 0)
el_free((ptr_t) b[i]);
el_free((ptr_t) be);
return (-1);
}
}
b[c->v] = NULL;
el->el_display = b;
@ -484,8 +488,12 @@ term_alloc_display(EditLine *el)
return (-1);
for (i = 0; i < c->v; i++) {
b[i] = (char *) el_malloc((size_t) (sizeof(char) * (c->h + 1)));
if (b[i] == NULL)
if (b[i] == NULL) {
while (--i >= 0)
el_free((ptr_t) b[i]);
el_free((ptr_t) be);
return (-1);
}
}
b[c->v] = NULL;
el->el_vdisplay = b;