From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH 1/2] Fix memory leak on `realloc' failure Date: Tue, 22 Apr 2014 22:25:56 +0200 Message-ID: <874n1lm7qj.fsf@pobox.com> References: <1397108266-18581-1-git-send-email-KAction@gnu.org> <20140410163648.MIXO2.198633.root@cdptpa-web07> <20140410165243.GA16599@localhost.kaction.name> <20140412065951.GA2532@localhost.kaction.name> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1398198388 32367 80.91.229.3 (22 Apr 2014 20:26:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 22 Apr 2014 20:26:28 +0000 (UTC) Cc: guile-devel@gnu.org To: Dmitry Bogatov Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Apr 22 22:26:23 2014 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WchGo-0006rL-Rw for guile-devel@m.gmane.org; Tue, 22 Apr 2014 22:26:22 +0200 Original-Received: from localhost ([::1]:57109 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WchGo-0004vX-G1 for guile-devel@m.gmane.org; Tue, 22 Apr 2014 16:26:22 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42194) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WchGf-0004vP-Ht for guile-devel@gnu.org; Tue, 22 Apr 2014 16:26:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WchGa-0005to-Q5 for guile-devel@gnu.org; Tue, 22 Apr 2014 16:26:13 -0400 Original-Received: from a-pb-sasl-quonix.pobox.com ([208.72.237.25]:63609 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WchGT-0005rc-PP; Tue, 22 Apr 2014 16:26:01 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 4DC0611958; Tue, 22 Apr 2014 16:26:01 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=2X1nOYQJmG+UNhFtCOjXb5f7sqI=; b=u57aiC LvhRVkHbGY1BRgc8uHx1XZoHYZMsm/0Sj/3VHw1gJwEx2wmgY4irW+SAuUy7BAO4 2cfxpE4Q+7RvM4rq7NRmJlLNLuQpFx1WEq9YEz+XHzOVw4d21/wCinvhrNISIfJd d93FuB+vgRywZQMVMJfDUJ0J2RZtyqaCbecoQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=ehAiOiIWscjkxLPz7ZoNG+d2T8oWkHZZ /j31AHiEVedd/IrRQu89LPKsZeTH8nKzBbRAm53AGpV99Nv2a0HH9MBA6Xr8aGkq lcwnIoBUTUSJL77hQ/2EYI5lfRIJIpYtfmBcdSgh82Cy3ZB/cUkVqwtB0Qz0YCtT WJcIMkvivGg= Original-Received: from a-pb-sasl-quonix.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 422F011957; Tue, 22 Apr 2014 16:26:01 -0400 (EDT) Original-Received: from badger (unknown [88.160.190.192]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTPSA id 7674711955; Tue, 22 Apr 2014 16:25:59 -0400 (EDT) In-Reply-To: <20140412065951.GA2532@localhost.kaction.name> (Dmitry Bogatov's message of "Sat, 12 Apr 2014 10:59:51 +0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-Pobox-Relay-ID: 510A0386-CA5C-11E3-A397-6F330E5B5709-02397024!a-pb-sasl-quonix.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 208.72.237.25 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:17099 Archived-At: On Sat 12 Apr 2014 08:59, Dmitry Bogatov writes: > * Dmitry Bogatov [2014-04-10 20:52:43+0400] >> > > + { >> > > + free (nargv); >> > > return 0L; >> > > + } >> > > else >> > > nargv[nargi++] = narg; >> > I don't understand this. In both cases, free() will be called with an >> > argument of 0, which does nothing. >> My bad. It does not fix problem, that if realloc fails, it does not free >> memory, but we blindly assign, losing pointer to previous memory >> chunk. > > Attached new version. Please, take a look. Applied, thanks. I altered the commit log; please take a look and submit in that format in the future. The "magit" emacs mode makes it easy to produce this format. Cheers, Andy -- http://wingolog.org/