git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-show: only chdir(prefix) when prefix is not NULL, and check for success
@ 2007-12-02  1:42 Johannes Schindelin
  0 siblings, 0 replies; only message in thread
From: Johannes Schindelin @ 2007-12-02  1:42 UTC (permalink / raw)
  To: git, gitster


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

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2007-12-02  1:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-02  1:42 [PATCH] git-show: only chdir(prefix) when prefix is not NULL, and check for success Johannes Schindelin

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 NNTP newsgroup(s).