Subject: lib/17163: libedit leaks memory
To: None <gnats-bugs@gnats.netbsd.org>
From: None <itojun@itojun.org>
List: netbsd-bugs
Date: 06/04/2002 18:46:59
>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 02:48:01 PDT 2002
>Closed-Date:
>Last-Modified:
>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:
>Unformatted: