git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Alex Riesen <raa.lkml@gmail.com>
To: Daniel Barkalow <barkalow@iabervon.org>
Cc: Junio C Hamano <junkio@cox.net>, git@vger.kernel.org
Subject: [PATCH] Fix builtin checkout crashing when given an invalid path
Date: Thu, 28 Feb 2008 17:30:47 +0100	[thread overview]
Message-ID: <20080228163047.GA4069@steel.home> (raw)

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---

Noticed in t2008, which actually passed, but silently removed
core-files (I saw segfaults in syslog) and did not properly check the
exit code.  The change for the t2008 comes as seperate patch, but it
should be noted that "! command" is *not* how you check for a command
to have failed. It could have crashed.

 builtin-checkout.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/builtin-checkout.c b/builtin-checkout.c
index 4a4bb8b..9579ff4 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -545,6 +545,10 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
 
 	if (argc) {
 		const char **pathspec = get_pathspec(prefix, argv);
+
+		if (!pathspec)
+			die("invalid path specification");
+
 		/* Checkout paths */
 		if (opts.new_branch || opts.force || opts.merge) {
 			if (argc == 1) {
-- 
1.5.4.3.253.g9f1d5



             reply	other threads:[~2008-02-28 16:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-28 16:30 Alex Riesen [this message]
2008-02-28 16:49 ` [PATCH] Expect the exit code of builtin checkout to be in portable range Alex Riesen
2008-02-28 20:52   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080228163047.GA4069@steel.home \
    --to=raa.lkml@gmail.com \
    --cc=barkalow@iabervon.org \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).