git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Fix builtin checkout crashing when given an invalid path

From
Alex Riesen <raa.lkml@gmail.com>
Date
Feb 28, 2008, 16:30 UTC
Message-ID
<20080228163047.GA4069@steel.home>
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
Next: Alex Riesen
Message 1 of 3 in “Fix builtin checkout crashing when given an invalid path”
  1. Fix builtin checkout crashing when given an invalid pathAlex Riesen, Feb 28, 2008
  2. Expect the exit code of builtin checkout to be in portable rangeAlex Riesen, Feb 28, 2008
  3. Junio C HamanoFeb 28, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.