Skip to content

Commit e0d082d

Browse files
committed
Merge branch 'coverity'
Coverity is a tool to analyze code statically, trying to find common (or not so common) problems before they occur in production. Coverity offers its services to Open Source software, and just like upstream Git, Git for Windows applied and was granted the use. While Coverity reports a lot of false positives due to Git's (ab-)use of the FLEX_ARRAY feature (where it declares a 0-byte or 1-byte array at the end of a struct, and then allocates a variable-length data structure holding a variable-length string at the end, so that the struct as well as the string can be released with a single free()), there were a few issues reported that are true positives, and not all of them were resource leaks in builtins (for which it is considered kind of okay to not release memory just before exit() is called anyway). This topic branch tries to address a couple of those issues. Note: there are a couple more issues left, either because they are tricky to resolve (in some cases, the custody of occasionally-allocated memory is very unclear) or because it is unclear whether they are false positives (due to the hard-to-reason-about nature of the code). It's a start, though. Signed-off-by: Johannes Schindelin <[email protected]>
2 parents a996933 + 2f6456b commit e0d082d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

http-backend.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,8 +681,10 @@ int cmd_main(int argc, const char **argv)
681681
if (!regexec(&re, dir, 1, out, 0)) {
682682
size_t n;
683683

684-
if (strcmp(method, c->method))
684+
if (strcmp(method, c->method)) {
685+
free(dir);
685686
return bad_request(&hdr, c);
687+
}
686688

687689
cmd = c;
688690
n = out[0].rm_eo - out[0].rm_so;
@@ -708,5 +710,7 @@ int cmd_main(int argc, const char **argv)
708710
max_request_buffer);
709711

710712
cmd->imp(&hdr, cmd_arg);
713+
free(dir);
714+
free(cmd_arg);
711715
return 0;
712716
}

0 commit comments

Comments
 (0)