From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13770 invoked by alias); 26 Jul 2007 14:07:22 -0000 Received: (qmail 13681 invoked by uid 22791); 26 Jul 2007 14:07:21 -0000 X-Spam-Check-By: sourceware.org Received: from omta04ps.mx.bigpond.com (HELO omta04ps.mx.bigpond.com) (144.140.83.156) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 26 Jul 2007 14:07:15 +0000 Received: from oaamta08ps.mx.bigpond.com ([58.174.193.252]) by omta04ps.mx.bigpond.com with ESMTP id <20070726140712.HBDQ1991.omta04ps.mx.bigpond.com@oaamta08ps.mx.bigpond.com>; Thu, 26 Jul 2007 14:07:12 +0000 Received: from bubble.grove.modra.org ([58.174.193.252]) by oaamta08ps.mx.bigpond.com with ESMTP id <20070726140712.CEHC3831.oaamta08ps.mx.bigpond.com@bubble.grove.modra.org>; Thu, 26 Jul 2007 14:07:12 +0000 Received: by bubble.grove.modra.org (Postfix, from userid 500) id 134EF22D385; Thu, 26 Jul 2007 23:37:12 +0930 (CST) Date: Thu, 26 Jul 2007 14:22:00 -0000 From: Alan Modra To: msnyder@sonic.net Cc: binutils@sourceware.org Subject: Re: [PATCH] linker.c, check for null return from bfd_hash_allocate Message-ID: <20070726140711.GN11649@bubble.grove.modra.org> Mail-Followup-To: msnyder@sonic.net, binutils@sourceware.org References: <6375.12.7.175.2.1185415194.squirrel@webmail.sonic.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6375.12.7.175.2.1185415194.squirrel@webmail.sonic.net> User-Agent: Mutt/1.5.9i X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2007-07/txt/msg00457.txt.bz2 On Wed, Jul 25, 2007 at 06:59:54PM -0700, msnyder@sonic.net wrote: > *** linker.c 24 Jul 2007 23:38:13 -0000 1.60 > --- linker.c 26 Jul 2007 01:55:13 -0000 > *************** bfd_section_already_linked_table_insert > *** 2933,2938 **** > --- 2933,2940 ---- > /* Allocate the memory from the same obstack as the hash table is > kept in. */ > l = bfd_hash_allocate (&_bfd_section_already_linked_table, sizeof *l); > + if (l == NULL) > + return; /* Should we abort? */ The proper fix is to change bfd_section_already_linked_table_insert to return a pass/fail status. Check the status in _bfd_elf_section_already_linked, _bfd_generic_section_already_linked, and on failure call info->einfo with a fatal error message. > l->sec = sec; > l->next = already_linked_list->entry; > already_linked_list->entry = l; > *************** already_linked_newfunc (struct bfd_hash_ > *** 2946,2951 **** > --- 2948,2956 ---- > struct bfd_section_already_linked_hash_entry *ret = > bfd_hash_allocate (table, sizeof *ret); > > + if (ret == NULL) > + return ret; > + > ret->entry = NULL; > > return &ret->root; This part is OK. -- Alan Modra Australia Development Lab, IBM