commit 89ae185cb4dd6d82b92a79daa8ef484b7da78ec3 from: Omar Polo date: Thu Sep 01 10:18:34 2022 UTC gotwebd: fix possible leaks when handling errors all very unlikely. part of a bigger diff that's ok stsp@ commit - 341fa7cacc77a0a56e7e6eebec0b591ea6d8003b commit + 89ae185cb4dd6d82b92a79daa8ef484b7da78ec3 blob - 2a02d38ffccd0d8d1fa5492ee3b3d193e0811efe blob + 9f6c80798c87976a9ecf28e0d6ea97f818197058 --- gotwebd/got_operations.c +++ gotwebd/got_operations.c @@ -350,12 +350,14 @@ got_get_repo_commits(struct request *c, int limit) return got_error_from_errno("asprintf"); if (asprintf(&repo_path, "%s/%s", srv->repos_path, - repo_dir->name) == -1) - return got_error_from_errno("asprintf"); + repo_dir->name) == -1) { + error = got_error_from_errno("asprintf"); + goto done; + } error = got_init_repo_commit(&repo_commit); if (error) - return error; + goto done; /* * XXX: jumping directly to a commit id via blob - 2cf872b749f021dc0d5851cce281f8c10c5ebafc blob + 314619a09979ee566fcfbb5f1cc283ba1336f39c --- gotwebd/gotweb.c +++ gotwebd/gotweb.c @@ -2073,9 +2073,8 @@ gotweb_get_repo_description(char **description, struct f = fopen(d_file, "r"); if (f == NULL) { - if (errno == ENOENT || errno == EACCES) - return NULL; - error = got_error_from_errno2("fopen", d_file); + if (errno != ENOENT && errno != EACCES) + error = got_error_from_errno2("fopen", d_file); goto done; } @@ -2092,7 +2091,7 @@ gotweb_get_repo_description(char **description, struct if (len == 0) { *description = strdup(""); if (*description == NULL) - return got_error_from_errno("strdup"); + error = got_error_from_errno("strdup"); goto done; }