threads / patch / 27260

patchshell: add missing initialization of argv0_path

Subject: [PATCH] shell: add missing initialization of argv0_path

## tl;dr

3 messages between May 5, 2011 and May 5, 2011. Diffs are folded; open one to read it.

replies: 2people: 3as markdown or json

Dima Sharov· May 5, 2011, 06:40 UTC · lore

According to c6dfb39 (remote-curl: add missing initialization of argv0_path, 2009-10-13), stand-alone programs (non-builtins) must call git_extract_argv0_path(argv[0]) in order to help builds that derive the installation prefix at runtime. Without this call, the program segfaults (or raises an assertion failure).

Signed-off-by: Dima Sharov <git.avalakvista@gmail.com>
---
shell.c |    2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
Show changes to shell.c +2 −0
diff --git a/shell.c b/shell.c
index dea4cfd..abb8622 100644
--- a/shell.c
+++ b/shell.c
@@ -137,6 +137,8 @@ int main(int argc, char **argv)
	int devnull_fd;
	int count;

+	git_extract_argv0_path(argv[0]);
+
	/*
	 * Always open file descriptors 0/1/2 to avoid clobbering files
	 * in die().  It also avoids not messing up when the pipes are
-- 
1.7.2.3
Johannes Sixt· May 5, 2011, 06:58 UTC · re: Dima Sharov · lore

Re: [PATCH] shell: add missing initialization of argv0_path

Am 5/5/2011 8:40, schrieb Dima Sharov:
Show 5 quoted lines
> According to c6dfb39 (remote-curl: add missing initialization of
> argv0_path, 2009-10-13), stand-alone programs (non-builtins)
> must call git_extract_argv0_path(argv[0]) in order to help builds
> that derive the installation prefix at runtime. Without this call,
> the program segfaults (or raises an assertion failure).

Good catch! I checked PROGRAM_OBJS in Makefile, and shell.c was the only one remaining that did not call this function.

-- Hannes
Junio C Hamano· May 5, 2011, 16:32 UTC · re: Johannes Sixt · lore

Re: [PATCH] shell: add missing initialization of argv0_path

Johannes Sixt <j.sixt@viscovery.net> writes:
Show 9 quoted lines
> Am 5/5/2011 8:40, schrieb Dima Sharov:
>> According to c6dfb39 (remote-curl: add missing initialization of
>> argv0_path, 2009-10-13), stand-alone programs (non-builtins)
>> must call git_extract_argv0_path(argv[0]) in order to help builds
>> that derive the installation prefix at runtime. Without this call,
>> the program segfaults (or raises an assertion failure).
>
> Good catch! I checked PROGRAM_OBJS in Makefile, and shell.c was the only
> one remaining that did not call this function.

Thanks for an Ack; the patch was corrupt but was trivial to fix-up. Will queue.

← back to recent threads