summaryrefslogtreecommitdiff
path: root/exec_cmd.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-12-22 12:27:01 -0800
committerJunio C Hamano <gitster@pobox.com>2014-12-22 12:27:01 -0800
commit6bcaff1a4fe4a3088348e706c149941c74d1ad61 (patch)
treea03cc8a4a3b8fa2cdf06bdbed93ee8a1aac2692d /exec_cmd.c
parent5109f2aaabcd7ce2c493bb663417c2dd4d5b81fe (diff)
parent59362e560d3c439e77768983b00eade08be9bc3e (diff)
downloadgit-6bcaff1a4fe4a3088348e706c149941c74d1ad61.tar.gz
Merge branch 'jc/exec-cmd-system-path-leak-fix'
The function sometimes returned a non-freeable memory and some other times returned a piece of memory that must be freed. * jc/exec-cmd-system-path-leak-fix: system_path(): always return free'able memory to the caller
Diffstat (limited to 'exec_cmd.c')
-rw-r--r--exec_cmd.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/exec_cmd.c b/exec_cmd.c
index 698e7526c4..8ab37b5f74 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c
@@ -6,7 +6,7 @@
static const char *argv_exec_path;
static const char *argv0_path;
-const char *system_path(const char *path)
+char *system_path(const char *path)
{
#ifdef RUNTIME_PREFIX
static const char *prefix;
@@ -16,7 +16,7 @@ const char *system_path(const char *path)
struct strbuf d = STRBUF_INIT;
if (is_absolute_path(path))
- return path;
+ return xstrdup(path);
#ifdef RUNTIME_PREFIX
assert(argv0_path);
@@ -34,8 +34,7 @@ const char *system_path(const char *path)
#endif
strbuf_addf(&d, "%s/%s", prefix, path);
- path = strbuf_detach(&d, NULL);
- return path;
+ return strbuf_detach(&d, NULL);
}
const char *git_extract_argv0_path(const char *argv0)