summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2010-10-23 18:53:11 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2010-10-23 18:53:11 +0000
commit8f087f5c116d861a586e0c18ac0c423886dac17b (patch)
tree83d5a432274ca71770d834835ce15a4d43d48d74
parent0ac5bacc58f8ff12a9420d985eb151924c829bcd (diff)
Don't leak the fd returned by mkstemp in vi_histedit error paths.
From zinovik.
-rw-r--r--lib/libedit/vi.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/libedit/vi.c b/lib/libedit/vi.c
index 85155df9711..6115ff0568e 100644
--- a/lib/libedit/vi.c
+++ b/lib/libedit/vi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vi.c,v 1.9 2010/06/30 00:05:35 nicm Exp $ */
+/* $OpenBSD: vi.c,v 1.10 2010/10/23 18:53:10 nicm Exp $ */
/* $NetBSD: vi.c,v 1.31 2009/12/30 22:37:40 christos Exp $ */
/*-
@@ -1013,10 +1013,15 @@ vi_histedit(EditLine *el, Int c)
len = (size_t)(el->el_line.lastchar - el->el_line.buffer);
#define TMP_BUFSIZ (EL_BUFSIZ * MB_LEN_MAX)
cp = el_malloc(TMP_BUFSIZ);
- if (cp == NULL)
+ if (cp == NULL) {
+ close(fd);
+ unlink(tempfile);
return CC_ERROR;
+ }
line = el_malloc(len * sizeof(*line));
if (line == NULL) {
+ close(fd);
+ unlink(tempfile);
el_free((ptr_t)cp);
return CC_ERROR;
}