{"thread":{"id":"11083","subject":"[PATCH] git-show: only chdir(prefix) when prefix is not NULL, and check for success","startedAt":"2007-12-02T01:42:06Z","lastAt":"2007-12-02T01:42:06Z","messageCount":1,"participants":["Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"61607","messageId":"Pine.LNX.4.64.0712020141530.27959@racer.site","threadId":"11083","inReplyTo":null,"subject":"[PATCH] git-show: only chdir(prefix) when prefix is not NULL, and check for success","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-12-02T01:42:06Z","receivedAt":"2007-12-02T01:42:06Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nWe blindly called \"chdir(prefix);\" and did not even check if it succeeded.\nFound by valgrind.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n builtin-log.c |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-log.c b/builtin-log.c\nindex 21f3b0f..0f38579 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -285,7 +285,8 @@ int cmd_show(int argc, const char **argv, const char *prefix)\n \tstruct object_array_entry *objects;\n \tint i, count, ret = 0;\n \n-\tchdir(prefix);\n+\tif (prefix && chdir(prefix))\n+\t\tdie (\"Could not change directory to '%s'\", prefix);\n \n \tgit_config(git_log_config);\n \tinit_revisions(&rev, prefix);\n-- \n1.5.3.6.2112.ge2263\n"}]}