From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16761 invoked by alias); 15 Aug 2007 00:01:16 -0000 Received: (qmail 16426 invoked by uid 22791); 15 Aug 2007 00:01:12 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 15 Aug 2007 00:01:06 +0000 Received: (qmail 4850 invoked from network); 15 Aug 2007 00:01:04 -0000 Received: from unknown (HELO localhost) (jimb@127.0.0.2) by mail.codesourcery.com with ESMTPA; 15 Aug 2007 00:01:04 -0000 To: msnyder@sonic.net Cc: gdb-patches@sourceware.org, bug-readline@gnu.org Subject: Re: PATCH: readline/histexpand.c, resource leak References: <10015.12.7.175.2.1185934493.squirrel@webmail.sonic.net> From: Jim Blandy Date: Wed, 15 Aug 2007 00:01:00 -0000 In-Reply-To: <10015.12.7.175.2.1185934493.squirrel@webmail.sonic.net> (msnyder@sonic.net's message of "Tue, 31 Jul 2007 19:14:53 -0700 (PDT)") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-08/txt/msg00301.txt.bz2 It seems to me that 'words' is a malloc'ed array of malloc'ed strings, so 'free (words)' still leaks storage. msnyder@sonic.net writes: > 2007-07-31 Michael Snyder > > * histexpand.c (history_find_word): Resource leak. > > Index: histexpand.c > =================================================================== > RCS file: /cvs/src/src/readline/histexpand.c,v > retrieving revision 1.6 > diff -p -r1.6 histexpand.c > *** histexpand.c 5 May 2006 18:26:12 -0000 1.6 > --- histexpand.c 1 Aug 2007 02:08:51 -0000 > *************** history_find_word (line, ind) > *** 1581,1588 **** > int i, wind; > > words = history_tokenize_internal (line, ind, &wind); > ! if (wind == -1 || words == 0) > return ((char *)NULL); > s = words[wind]; > for (i = 0; i < wind; i++) > free (words[i]); > --- 1581,1594 ---- > int i, wind; > > words = history_tokenize_internal (line, ind, &wind); > ! if (words == NULL) > return ((char *)NULL); > + if (wind == -1) > + { > + free (words); > + return ((char *)NULL); > + } > + > s = words[wind]; > for (i = 0; i < wind; i++) > free (words[i]);