NetBSD Problem Report #17163

Received: (qmail 10161 invoked by uid 605); 4 Jun 2002 09:47:38 -0000
Message-Id: <20020604094659.056247B9@starfruit.itojun.org>
Date: Tue,  4 Jun 2002 18:46:59 +0900 (JST)
From: itojun@itojun.org
Sender: gnats-bugs-owner@netbsd.org
Reply-To: itojun@itojun.org
To: gnats-bugs@gnats.netbsd.org
Subject: libedit leaks memory
X-Send-Pr-Version: 3.95

>Number:         17163
>Category:       lib
>Synopsis:       libedit leaks memory
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jun 04 09:48:01 +0000 2002
>Closed-Date:    
>Last-Modified:  Sat Oct 26 17:53:00 +0000 2002
>Originator:     Jun-ichiro itojun Hagino
>Release:        NetBSD 1.6A
>Organization:
	itojun.org
>Environment:
System: NetBSD starfruit.itojun.org 1.6A NetBSD 1.6A (STARFRUIT) #29: Mon Jun 3 11:35:45 JST 2002 itojun@starfruit.itojun.org:/usr/home/itojun/NetBSD/src/sys/arch/i386/compile/STARFRUIT i386
Architecture: i386
Machine: i386
>Description:
	libedit uses expressions like this:
		p = realloc(p, size);
	it will leak memory on failure.
	the correct construct is;
		q = realloc(p, size);
		if (!q) {
			free(p);
			return FAIL;
		}
		p = q;
>How-To-Repeat:
	code inspection
>Fix:
>Release-Note:
>Audit-Trail:

From: David Laight <david@l8s.co.uk>
To: gnats-bugs@gnats.netbsd.org
Cc:  
Subject: lib/17163
Date: Sat, 26 Oct 2002 18:53:26 +0100

 This is all a huge bag of worms.

 I started trying to fix this (while fixing other broken bits
 of libedit) but it is all too hard (and tedious).
 Large chunks of the libedit code behave badly if any
 of the malloc() calls fails.
 They typically either core dump or leak (more) memory.
 OTOH it isn't obvious what to do in many cases, the structure
 doesn't allow errors to be returned - and in any case if
 malloc is failing getting them to the user starts becoming hard!

 	David

 -- 
 David Laight: david@l8s.co.uk
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(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.