commit - 254707814d845a2c4a93c473ad51e9e1b28c716f
commit + 2acfca77da819090c3caac77635cb2c2bc4ebe14
blob - 9f91bda196d6d4744786e5335ea8b475d850df49
blob + 97a6d9ef1386a1ea8f3b9b8d666bd8b3bcbf27b2
--- lib/diff.c
+++ lib/diff.c
FILE *outfile)
{
const struct got_error *err;
- struct got_blob_object *blob;
- struct got_object *obj;
+ struct got_blob_object *blob = NULL;
+ struct got_object *obj = NULL;
err = got_object_open(&obj, repo, id);
if (err)
return err;
- err = got_object_blob_open(&blob, repo, obj, 8192);
- if (err != NULL)
- return err;
- return got_diff_blob(NULL, blob, NULL, NULL, outfile);
+ err = got_object_blob_open(&blob, repo, obj, 8192);
+ if (err)
+ goto done;
+ err = got_diff_blob(NULL, blob, NULL, NULL, outfile);
+done:
+ got_object_close(obj);
+ if (blob)
+ got_object_blob_close(blob);
+ return err;
}
static const struct got_error *
}
err = got_object_blob_open(&blob1, repo, obj1, 8192);
- if (err != NULL) {
- err = got_error(GOT_ERR_FILE_OPEN);
+ if (err)
goto done;
- }
err = got_object_blob_open(&blob2, repo, obj2, 8192);
- if (err != NULL) {
- err = got_error(GOT_ERR_FILE_OPEN);
+ if (err)
goto done;
- }
err = got_diff_blob(blob1, blob2, NULL, NULL, outfile);
FILE *outfile)
{
const struct got_error *err;
- struct got_blob_object *blob;
- struct got_object *obj;
+ struct got_blob_object *blob = NULL;
+ struct got_object *obj = NULL;
err = got_object_open(&obj, repo, id);
if (err)
return err;
- err = got_object_blob_open(&blob, repo, obj, 8192);
- if (err != NULL)
- return err;
- return got_diff_blob(blob, NULL, NULL, NULL, outfile);
+ err = got_object_blob_open(&blob, repo, obj, 8192);
+ if (err)
+ goto done;
+ err = got_diff_blob(blob, NULL, NULL, NULL, outfile);
+done:
+ got_object_close(obj);
+ if (blob)
+ got_object_blob_close(blob);
+ return err;
}
static const struct got_error *