[PATCH] git-show: only chdir(prefix) when prefix is not NULL, and check for success

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

 



We blindly called "chdir(prefix);" and did not even check if it succeeded.
Found by valgrind.

Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx>
---
 builtin-log.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/builtin-log.c b/builtin-log.c
index 21f3b0f..0f38579 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -285,7 +285,8 @@ int cmd_show(int argc, const char **argv, const char *prefix)
 	struct object_array_entry *objects;
 	int i, count, ret = 0;
 
-	chdir(prefix);
+	if (prefix && chdir(prefix))
+		die ("Could not change directory to '%s'", prefix);
 
 	git_config(git_log_config);
 	init_revisions(&rev, prefix);
-- 
1.5.3.6.2112.ge2263

-
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