Skip to content

Commit eef75d2

Browse files
avargitster
authored andcommitted
http-backend.c: fix "dir" and "cmd_arg" leaks in cmd_main()
Free the "dir" variable after we're done with it. Before 917adc0 (http-backend: add GIT_PROJECT_ROOT environment var, 2009-10-30) there was no leak here, as we'd get it via getenv(), but since 917adc0 we've xstrdup()'d it (or the equivalent), so we need to free() it. We also need to free the "cmd_arg" variable, which has been leaked ever since it was added in 2f4038a (Git-aware CGI to provide dumb HTTP transport, 2009-10-30). Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9f24f3c commit eef75d2

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

http-backend.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,7 @@ int cmd_main(int argc, const char **argv)
786786
if (!getenv("GIT_HTTP_EXPORT_ALL") &&
787787
access("git-daemon-export-ok", F_OK) )
788788
not_found(&hdr, "Repository not exported: '%s'", dir);
789+
free(dir);
789790

790791
http_config();
791792
max_request_buffer = git_env_ulong("GIT_HTTP_MAX_REQUEST_BUFFER",
@@ -795,5 +796,6 @@ int cmd_main(int argc, const char **argv)
795796
setenv(GIT_PROTOCOL_ENVIRONMENT, proto_header, 0);
796797

797798
cmd->imp(&hdr, cmd_arg);
799+
free(cmd_arg);
798800
return 0;
799801
}

0 commit comments

Comments
 (0)