NetBSD Problem Report #39721
From www@NetBSD.org Thu Oct 9 04:18:48 2008
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by narn.NetBSD.org (Postfix) with ESMTP id D193463BA54
for <gnats-bugs@gnats.netbsd.org>; Thu, 9 Oct 2008 04:18:47 +0000 (UTC)
Message-Id: <20081009041847.8A77763B88A@narn.NetBSD.org>
Date: Thu, 9 Oct 2008 04:18:47 +0000 (UTC)
From: abutter.gao@gmail.com
Reply-To: abutter.gao@gmail.com
To: gnats-bugs@NetBSD.org
Subject: Memory leak in exception branch of the curdir_push function in usr.bin/config/scan.l
X-Send-Pr-Version: www-1.0
>Number: 39721
>Category: bin
>Synopsis: Memory leak in exception branch of the curdir_push function in usr.bin/config/scan.l
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: dholland
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Oct 09 04:20:01 +0000 2008
>Closed-Date: Fri Nov 14 09:14:21 +0000 2008
>Last-Modified: Fri Nov 14 09:14:21 +0000 2008
>Originator: Gao Ya'nan
>Release: NetBSD-current and NetBSD-4.0
>Organization:
>Environment:
NetBSD abutter.foo.org 4.0 NetBSD 4.0 (GENERIC) #0: Sun Dec 16 00:20:10 PST 2007 builds@wb34:/home/builds/ab/netbsd-4-0-RELEASE/i386/200712160005Z-obj/home/builds/ab/netbsd-4-0-RELEASE/src/sys/arch/i386/compile/GENERIC i386
>Description:
----------------------------------->cut<----------------------------------------
static int
curdir_push(const char *fname)
{
struct prefix *pf;
char *p, *d, *f;
/* Set up the initial "current directory" for include directives. */
d = dirname(f = estrdup(fname));
if (*d == '/')
p = estrdup(d);
else {
char *cwd, buf[PATH_MAX];
if ((cwd = getcwd(buf, sizeof(buf))) == NULL)
return (-1);
p = emalloc(strlen(cwd) + strlen(d) + 2);
sprintf(p, "%s/%s", cwd, d);
}
free(f);
----------------------------------->cut<----------------------------------------
When everything goes well, f will be freed, but not when the getcwd fails.
>How-To-Repeat:
Review the code
>Fix:
free f in exception branch as well
>Release-Note:
>Audit-Trail:
From: "David A. Holland" <dholland@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/39721 CVS commit: src/usr.bin/config
Date: Thu, 9 Oct 2008 07:18:16 +0000 (UTC)
Module Name: src
Committed By: dholland
Date: Thu Oct 9 07:18:15 UTC 2008
Modified Files:
src/usr.bin/config: scan.l
Log Message:
Avoid memory leak in error case. From Gao Ya'nan in PR bin/39721.
To generate a diff of this commit:
cvs rdiff -r1.10 -r1.11 src/usr.bin/config/scan.l
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->pending-pullups
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Thu, 09 Oct 2008 07:35:21 +0000
State-Changed-Why:
fixed in HEAD; pullup-4 #1212 and pullup-3 #1974 in the queue.
Responsible-Changed-From-To: bin-bug-people->dholland
Responsible-Changed-By: dholland@NetBSD.org
Responsible-Changed-When: Thu, 09 Oct 2008 07:36:25 +0000
Responsible-Changed-Why:
I patched it.
From: Soren Jacobsen <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/39721 CVS commit: [netbsd-4] src/usr.bin/config
Date: Fri, 31 Oct 2008 21:14:05 +0000 (UTC)
Module Name: src
Committed By: snj
Date: Fri Oct 31 21:14:05 UTC 2008
Modified Files:
src/usr.bin/config [netbsd-4]: scan.l
Log Message:
Pull up following revision(s) (requested by dholland in ticket #1212):
usr.bin/config/scan.l: revision 1.11
Avoid memory leak in error case. From Gao Ya'nan in PR bin/39721.'
To generate a diff of this commit:
cvs rdiff -r1.5 -r1.5.2.1 src/usr.bin/config/scan.l
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: Soren Jacobsen <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/39721 CVS commit: [netbsd-3] src/usr.sbin/config
Date: Fri, 14 Nov 2008 03:16:54 +0000 (UTC)
Module Name: src
Committed By: snj
Date: Fri Nov 14 03:16:54 UTC 2008
Modified Files:
src/usr.sbin/config [netbsd-3]: scan.l
Log Message:
Pull up following revision(s) (requested by dholland in ticket #1974):
usr.bin/config/scan.l: revision 1.11
Avoid memory leak in error case. From Gao Ya'nan in PR bin/39721.
To generate a diff of this commit:
cvs rdiff -r1.44 -r1.44.2.1 src/usr.sbin/config/scan.l
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: pending-pullups->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Fri, 14 Nov 2008 09:14:21 +0000
State-Changed-Why:
Fixed and pulled up; thanks for the report.
>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.