NetBSD Problem Report #45843
From www@NetBSD.org Mon Jan 16 11:45:06 2012
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by www.NetBSD.org (Postfix) with ESMTP id 93EA363BFD0
for <gnats-bugs@gnats.NetBSD.org>; Mon, 16 Jan 2012 11:45:06 +0000 (UTC)
Message-Id: <20120116114506.080B763B931@www.NetBSD.org>
Date: Mon, 16 Jan 2012 11:45:06 +0000 (UTC)
From: henning.petersen@t-online.de
Reply-To: henning.petersen@t-online.de
To: gnats-bugs@NetBSD.org
Subject: Resource leak in vi.c.
X-Send-Pr-Version: www-1.0
>Number: 45843
>Category: lib
>Synopsis: Resource leak in vi.c.
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: lib-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Jan 16 11:50:00 +0000 2012
>Closed-Date: Mon Jan 16 16:54:03 +0000 2012
>Last-Modified: Mon Jan 16 16:54:03 +0000 2012
>Originator: Henning Petersen
>Release: NetBSD-current
>Organization:
>Environment:
>Description:
Resource leak in error path.
In case cp == NULL change order of close and unlink.
>How-To-Repeat:
>Fix:
diff -u -p -r1.42 vi.c
--- lib/libedit/vi.c 18 Nov 2011 20:24:21 -0000 1.42
+++ lib/libedit/vi.c 16 Jan 2012 10:50:00 -0000
@@ -1022,13 +1022,15 @@ vi_histedit(EditLine *el, Int c __attrib
#define TMP_BUFSIZ (EL_BUFSIZ * MB_LEN_MAX)
cp = el_malloc(TMP_BUFSIZ * sizeof(*cp));
if (cp == NULL) {
- unlink(tempfile);
close(fd);
+ unlink(tempfile);
return CC_ERROR;
}
line = el_malloc(len * sizeof(*line) + 1);
if (line == NULL) {
+ close(fd);
+ unlink(tempfile);
el_free(cp);
return CC_ERROR;
}
Strncpy(line, el->el_line.buffer, len);
>Release-Note:
>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/45843 CVS commit: src/lib/libedit
Date: Mon, 16 Jan 2012 09:57:46 -0500
Module Name: src
Committed By: christos
Date: Mon Jan 16 14:57:46 UTC 2012
Modified Files:
src/lib/libedit: vi.c
Log Message:
PR/45843: Henning Petersen: Fix resource leak on error.
To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/lib/libedit/vi.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Mon, 16 Jan 2012 16:54:03 +0000
State-Changed-Why:
Christos fixed it, thanks
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.