From mboxrd@z Thu Jan 1 00:00:00 1970 From: Neil Horman Subject: [PATCH v2] git cherry-pick: Add NULL check to sequencer parsing of HEAD Date: Thu, 3 May 2012 08:10:22 -0400 Message-ID: <1336047022-3194-1-git-send-email-nhorman@tuxdriver.com> References: <1336044026-16897-1-git-send-email-nhorman@tuxdriver.com> Cc: mmueller@vigilantsw.com, rene.scharfe@lsrfire.ath.cx, Matthieu.Moy@grenoble-inp.fr, gitster@pobox.com, Neil Horman To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Thu May 03 14:10:55 2012 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SPury-0000J0-65 for gcvg-git-2@plane.gmane.org; Thu, 03 May 2012 14:10:50 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752909Ab2ECMKp (ORCPT ); Thu, 3 May 2012 08:10:45 -0400 Received: from charlotte.tuxdriver.com ([70.61.120.58]:51838 "EHLO smtp.tuxdriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752482Ab2ECMKp (ORCPT ); Thu, 3 May 2012 08:10:45 -0400 Received: from hmsreliant.think-freely.org ([2001:470:8:a08:7aac:c0ff:fec2:933b] helo=localhost) by smtp.tuxdriver.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1SPurk-0004qD-Nx; Thu, 03 May 2012 08:10:42 -0400 X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1336044026-16897-1-git-send-email-nhorman@tuxdriver.com> X-Spam-Score: -0.2 (/) X-Spam-Status: No Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: Michael Mueller noted that a feature I recently added failed to check the return of lookup_commit to ensure that it was not NULL. I don't think a NULL can actually happen in the this particular use case, but regardless it seems a good idea to check. Signed-off-by: Neil Horman --- sequencer.c | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) diff --git a/sequencer.c b/sequencer.c index f83cdfd..ded0b76 100644 --- a/sequencer.c +++ b/sequencer.c @@ -261,7 +261,16 @@ static int is_index_unchanged(void) return error(_("Could not resolve HEAD commit\n")); head_commit = lookup_commit(head_sha1); - if (!head_commit || parse_commit(head_commit)) + + /* + * If head_commit is NULL, just return, as check_commit, + * called from lookup_commit, would have indicated that + * head_commit is not a commit object already. + */ + if (!head_commit) + return -1; + + if (parse_commit(head_commit)) return error(_("could not parse commit %s\n"), sha1_to_hex(head_commit->object.sha1)); -- 1.7.7.6