commit 4b60fecedffa10e9ad1531cab9b5827c17e9d059 from: Stefan Sperling date: Wed Jan 29 13:25:54 2020 UTC call strdup("") instead of asprintf(&var, "") commit - 88d59c36623f1c67164472d51164b934416b649f commit + 4b60fecedffa10e9ad1531cab9b5827c17e9d059 blob - 639f8599deb7df9efd021f26555ac4f87a5273ce blob + 1ec59fcb2d686c29ccf23365cf46cbfb8d164bf6 --- gotweb/gotweb.c +++ gotweb/gotweb.c @@ -1348,10 +1348,7 @@ gw_get_repo_description(struct gw_trans *gw_trans, cha free(d_file); return description; err: - if (asprintf(&description, "%s", "") == -1) - return NULL; - - return description; + return strdup(""); } static char * @@ -1442,11 +1439,8 @@ gw_get_repo_age(struct gw_trans *gw_trans, char *dir, if (strncmp(repo_ref, "refs/heads/", 11) == 0) is_head = 1; - if (gw_trans->gw_conf->got_show_repo_age == false) { - if (asprintf(&repo_age, "") == -1) - return NULL; - return repo_age; - } + if (gw_trans->gw_conf->got_show_repo_age == false) + return strdup(""); error = got_repo_open(&repo, dir, NULL); if (error) @@ -1490,8 +1484,7 @@ gw_get_repo_age(struct gw_trans *gw_trans, char *dir, committer_time = cmp_time; repo_age = gw_get_time_str(committer_time, ref_tm); } else - if (asprintf(&repo_age, "") == -1) - return NULL; + return strdup(""); got_ref_list_free(&refs); free(id); return repo_age; @@ -1657,10 +1650,7 @@ gw_get_repo_owner(struct gw_trans *gw_trans, char *dir free(d_file); return owner; err: - if (asprintf(&owner, "%s", "") == -1) - return NULL; - - return owner; + return strdup(""); } static char *