From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=38371 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oeprk-0005D5-AD for qemu-devel@nongnu.org; Fri, 30 Jul 2010 09:43:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oepri-0002Yv-UT for qemu-devel@nongnu.org; Fri, 30 Jul 2010 09:43:12 -0400 Received: from fe01x03-cgp.akado.ru ([77.232.31.164]:62156 helo=akado.ru) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oepri-0002YW-ON for qemu-devel@nongnu.org; Fri, 30 Jul 2010 09:43:10 -0400 Date: Fri, 30 Jul 2010 17:42:26 +0400 (MSD) From: malc Subject: Re: [Qemu-devel] [PATCH] linux-user: Protect against allocation failure in load_symbols. In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jay Foad Cc: Richard Henderson , qemu-devel@nongnu.org On Fri, 30 Jul 2010, Jay Foad wrote: > > + /* Attempt to free the storage associated with the local symbols > > + that we threw away. Whether or not this has any effect on the > > + memory allocation depends on the malloc implementation and how > > + many symbols we managed to discard. */ > > syms = realloc(syms, nsyms * sizeof(*syms)); > > + if (syms == NULL) { > > + free(s); > > + free(strings); > > + return; > > + } > > If realloc() fails it leaves the original object unchanged, so can't > you just write: Life is not as simple as one would like it to be. http://www.mail-archive.com/qemu-devel@nongnu.org/msg22137.html > > t = realloc(syms, nsyms * sizeof(*syms)); > if (t != NULL) { > syms = t; > } > > ? > > Jay. > -- mailto:av1474@comtv.ru