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
This commit is contained in:
Junio C Hamano
2014-12-22 12:27:01 -08:00
4 changed files with 21 additions and 12 deletions

View File

@ -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)