commit 0d8d489a9ef3cda200d0e71337bc1b6d1c7bc03f from: Omar Polo date: Thu Jul 28 14:26:46 2022 UTC gotwebd: simplify got_output_file_blob loop there's no need to distinguish between plain text blob and a binary one in the output, just send it chunk by chunk. ok tracey@ commit - d4d45e4372f118778894438b90f9ef5ad70c7020 commit + 0d8d489a9ef3cda200d0e71337bc1b6d1c7bc03f blob - 7bb2fcd49dd35d487dc9e0d84ae02704e298a672 blob + 2ae01968126f6f9afdd84baa6e5766e042c53a25 --- gotwebd/got_operations.c +++ gotwebd/got_operations.c @@ -1196,8 +1196,7 @@ got_output_file_blob(struct request *c) struct got_reflist_head refs; struct got_blob_object *blob = NULL; char *path = NULL, *in_repo_path = NULL; - int obj_type, set_mime = 0, type = 0, fd = -1; - char *buf_output = NULL; + int obj_type, set_mime = 0, fd = -1; size_t len, hdrlen; const uint8_t *buf; @@ -1269,7 +1268,6 @@ got_output_file_blob(struct request *c) error->msg); goto done; } - type = 0; } else { error = gotweb_render_content_type(c, "text/plain"); @@ -1278,23 +1276,10 @@ got_output_file_blob(struct request *c) error->msg); goto done; } - type = 1; } } set_mime = 1; - if (type) { - buf_output = calloc(len - hdrlen + 1, - sizeof(*buf_output)); - if (buf_output == NULL) { - error = got_error_from_errno("calloc"); - goto done; - } - memcpy(buf_output, buf, len - hdrlen); - fcgi_gen_response(c, buf_output); - free(buf_output); - buf_output = NULL; - } else - fcgi_gen_binary_response(c, buf, len - hdrlen); + fcgi_gen_binary_response(c, buf, len - hdrlen); hdrlen = 0; } while (len != 0); @@ -1305,7 +1290,6 @@ done: error = got_error_from_errno("close"); if (blob) got_object_blob_close(blob); - free(buf_output); free(in_repo_path); free(commit_id); free(path);