commit - 704b89c4330d9641c93302516a59957a847736c1
commit + cb5e38fd43cb415cf405819e2cd437067cbf4397
blob - 7147a9755c2e0788c9ee549a1d956e32fe1c80b9
blob + a59aa24e783ca60c92019b12f4a166d4a4fe70ab
--- libexec/got-read-pack/got-read-pack.c
+++ libexec/got-read-pack/got-read-pack.c
{
const struct got_error *err = NULL;
struct got_imsg_packed_object iobj;
- struct got_object *obj;
+ struct got_object *obj = NULL;
struct got_commit_object *commit = NULL;
- uint8_t *buf;
+ uint8_t *buf = NULL;
size_t len;
struct got_object_id id;
size_t datalen;
err = got_packfile_extract_object_to_mem(&buf, &len, obj, pack);
if (err)
- return err;
+ goto done;
obj->size = len;
err = got_object_parse_commit(&commit, buf, len);
- free(buf);
- if (err) {
- got_object_close(obj);
- return err;
- }
+ if (err)
+ goto done;
err = got_privsep_send_commit(ibuf, commit);
- got_object_commit_close(commit);
+done:
+ free(buf);
+ got_object_close(obj);
+ if (commit)
+ got_object_commit_close(commit);
if (err) {
if (err->code == GOT_ERR_PRIVSEP_PIPE)
err = NULL;
struct got_imsg_packed_object iobj;
struct got_object *obj = NULL;
struct got_tree_object *tree = NULL;
- uint8_t *buf;
+ uint8_t *buf = NULL;
size_t len;
struct got_object_id id;
size_t datalen;
err = got_packfile_extract_object_to_mem(&buf, &len, obj, pack);
if (err)
- return err;
+ goto done;
obj->size = len;
err = got_object_parse_tree(&tree, buf, len);
- free(buf);
+ if (err)
+ goto done;
err = got_privsep_send_tree(ibuf, tree);
- if (obj)
- got_object_close(obj);
- got_object_tree_close(tree);
+done:
+ free(buf);
+ got_object_close(obj);
+ if (tree)
+ got_object_tree_close(tree);
if (err) {
if (err->code == GOT_ERR_PRIVSEP_PIPE)
err = NULL;
err = got_error_from_errno("fclose");
if (accumfile && fclose(accumfile) != 0 && err == NULL)
err = got_error_from_errno("fclose");
- if (obj)
- got_object_close(obj);
+ got_object_close(obj);
if (err && err->code != GOT_ERR_PRIVSEP_PIPE)
got_privsep_send_error(ibuf, err);
struct got_imsg_packed_object iobj;
struct got_object *obj = NULL;
struct got_tag_object *tag = NULL;
- uint8_t *buf;
+ uint8_t *buf = NULL;
size_t len;
struct got_object_id id;
size_t datalen;
err = got_packfile_extract_object_to_mem(&buf, &len, obj, pack);
if (err)
- return err;
+ goto done;
obj->size = len;
err = got_object_parse_tag(&tag, buf, len);
- free(buf);
if (err)
- return err;
+ goto done;
err = got_privsep_send_tag(ibuf, tag);
- if (obj)
- got_object_close(obj);
- got_object_tag_close(tag);
+done:
+ free(buf);
+ got_object_close(obj);
+ if (tag)
+ got_object_tag_close(tag);
if (err) {
if (err->code == GOT_ERR_PRIVSEP_PIPE)
err = NULL;