From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Shawn O. Pearce" Subject: Re: [PATCH maint] builtin-merge.c: fix memory under-allocation Date: Thu, 9 Oct 2008 08:13:00 -0700 Message-ID: <20081009151300.GS8203@spearce.org> References: <20081009001727.GP536@genesis.frugalware.org> <0LPLRUZaEHuEZTri_v38ySJHqYAhrfOpOkyUviUH9eOrx8IXBEAzYA@cipher.nrlssc.navy.mil> <7vmyheowcr.fsf@gitster.siamese.dyndns.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Cc: Junio C Hamano , Miklos Vajna , Git Mailing List To: Brandon Casey X-From: git-owner@vger.kernel.org Thu Oct 09 17:18:52 2008 Return-path: Envelope-to: gcvg-git-2@gmane.org Received: from vger.kernel.org ([209.132.176.167]) by lo.gmane.org with esmtp (Exim 4.50) id 1KnxDT-0002Rb-5l for gcvg-git-2@gmane.org; Thu, 09 Oct 2008 17:14:15 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760021AbYJIPND (ORCPT ); Thu, 9 Oct 2008 11:13:03 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1760018AbYJIPND (ORCPT ); Thu, 9 Oct 2008 11:13:03 -0400 Received: from george.spearce.org ([209.20.77.23]:51942 "EHLO george.spearce.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756222AbYJIPNB (ORCPT ); Thu, 9 Oct 2008 11:13:01 -0400 Received: by george.spearce.org (Postfix, from userid 1001) id 2FA373835F; Thu, 9 Oct 2008 15:13:00 +0000 (UTC) Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17+20080114 (2008-01-14) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: Brandon Casey wrote: > Junio C Hamano wrote: > > Brandon Casey writes: > >> I didn't mean to imply that the memory under-allocation > >> was caused by a change in variable type in this case. Re-reading my commit > >> message, maybe it sounds like that. > > > > Yeah, it does. I was scratching my head and had to read the patch three > > times until I got it (yes, I am especially slower than usual today, as the > > reason I am reading mails right now is because I am jetlagged and cannot > > sleep). > > If it's not too late, maybe this would make a better commit message: Nope, I didn't get around to the patch until now. Better message is being used... ;-) Thanks everyone. > --->8--- > builtin-merge.c: allocate correct amount of memory > > Fix two memory allocation errors which allocate space for a pointer rather > than enough space for the structure itself. > > This: > > struct commit_list *parent = xmalloc(sizeof(struct commit_list *)); > > should have been this: > > struct commit_list *parent = xmalloc(sizeof(struct commit_list)); > > But while we're at it, change the allocation to reference the variable it is > allocating memory for to try to prevent a similar mistake, for example if the > type is changed, in the future. > > Signed-off-by: Brandon Casey -- Shawn.