From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=55475 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OepGV-00014T-Tr for qemu-devel@nongnu.org; Fri, 30 Jul 2010 09:04:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OepGS-0008WD-Eu for qemu-devel@nongnu.org; Fri, 30 Jul 2010 09:04:43 -0400 Received: from mail-gx0-f173.google.com ([209.85.161.173]:41829) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OepGS-0008Vu-Cf for qemu-devel@nongnu.org; Fri, 30 Jul 2010 09:04:40 -0400 Received: by gxk19 with SMTP id 19so686770gxk.4 for ; Fri, 30 Jul 2010 06:04:39 -0700 (PDT) MIME-Version: 1.0 Date: Fri, 30 Jul 2010 14:04:38 +0100 Message-ID: Subject: Re: [Qemu-devel] [PATCH] linux-user: Protect against allocation failure in load_symbols. From: Jay Foad Content-Type: text/plain; charset=UTF-8 List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson Cc: qemu-devel@nongnu.org > + /* 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: t = realloc(syms, nsyms * sizeof(*syms)); if (t != NULL) { syms = t; } ? Jay.