commit 8463025419989fa48e0b637d82db3c9c11119aaf from: Omar Polo via: Thomas Adam date: Fri Sep 02 15:54:01 2022 UTC gotwebd: fix leak in gotweb_init_querystring in error path if strdup fails we fail to free the querystring Found by clang' scan-build. commit - 1510f72d86432ddfe0f08cc35fe89497c82bf7f1 commit + 8463025419989fa48e0b637d82db3c9c11119aaf blob - 61bc911fa12a4be1f7cf0e0519e4d09df8edb09c blob + ffabc99ee4368c91f33e9d6c1dd010f6f07af62d --- gotwebd/gotweb.c +++ gotwebd/gotweb.c @@ -353,14 +353,17 @@ gotweb_init_querystring(struct querystring **qs) if (*qs == NULL) return got_error_from_errno2("%s: calloc", __func__); - (*qs)->action = INDEX; - (*qs)->commit = NULL; - (*qs)->file = NULL; - (*qs)->folder = NULL; (*qs)->headref = strdup("HEAD"); if ((*qs)->headref == NULL) { + free(*qs); + *qs = NULL; return got_error_from_errno2("%s: strdup", __func__); } + + (*qs)->action = INDEX; + (*qs)->commit = NULL; + (*qs)->file = NULL; + (*qs)->folder = NULL; (*qs)->index_page = 0; (*qs)->index_page_str = NULL; (*qs)->path = NULL;