From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7514 invoked by alias); 23 Nov 2014 09:56:34 -0000 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 Received: (qmail 7505 invoked by uid 89); 23 Nov 2014 09:56:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Sun, 23 Nov 2014 09:56:32 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 376881166A2; Sun, 23 Nov 2014 04:56:31 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id W85hyguffgrK; Sun, 23 Nov 2014 04:56:31 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 9D641116679; Sun, 23 Nov 2014 04:56:30 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id B6AE640F79; Sun, 23 Nov 2014 13:56:29 +0400 (RET) Date: Sun, 23 Nov 2014 09:56:00 -0000 From: Joel Brobecker To: bug-hurd@gnu.org, thomas@codesourcery.com, gdb-patches@sourceware.org Subject: Re: [PATCH,Hurd] Fix deallocation after proc_getprocinfo call Message-ID: <20141123095629.GF5774@adacore.com> References: <20141102152537.GG2991@type.youpi.perso.aquilenet.fr> <20141123074452.GC7136@adacore.com> <20141123091347.GV4576@type.youpi.perso.aquilenet.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20141123091347.GV4576@type.youpi.perso.aquilenet.fr> User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2014-11/txt/msg00561.txt.bz2 > > > - vm_deallocate (mach_task_self (), (vm_address_t) pi, pi_len); > > > + vm_deallocate (mach_task_self (), (vm_address_t) pi, pi_len * sizeof (*(procinfo_t) 0)); > > > > Suggest using "sizeof (struct procinfo)", which I think is better > > than dereferencing a NULL pointer. This is based on guessing that > > type procinfo_t is a pointer to struct procinfo, as suggested by > > the code in inf_validate_procinfo. > > Not, that is not the same: struct procinfo has an open array at its end > (threadinfos[0]), and thus the actually allocated size is variable. OK. I don't know the code well enough to make any better suggestion. The above does look unusual to me, but if it works and seems to be the only correct way, let's go with that. Should I push your patch? -- Joel