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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

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


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux