commit - d2483d56ac80deca571cff32a14bef0dd238bfa6
commit + 46f6a3467a8a363294b271ee81bba8d96be03f91
blob - bb66caa58e383b540e51ea5efe6f0c6eba29fb7d
blob + 621f9b5789fafceb7c5bc95156ef5dd6b791d901
--- tog/tog.c
+++ tog/tog.c
switch (obj_type) {
case GOT_OBJ_TYPE_COMMIT:
- *commit_id = obj_id;
break;
case GOT_OBJ_TYPE_TAG:
err = got_object_open_as_tag(&tag, repo, obj_id);
if (err)
goto done;
- free(obj_id);
err = got_object_get_type(&obj_type, repo,
got_object_tag_get_object_id(tag));
if (err)
err = got_error(GOT_ERR_OBJ_TYPE);
goto done;
}
- *commit_id = got_object_id_dup(
- got_object_tag_get_object_id(tag));
- if (*commit_id == NULL) {
+ free(obj_id);
+ obj_id = got_object_id_dup(got_object_tag_get_object_id(tag));
+ if (obj_id == NULL) {
err = got_error_from_errno("got_object_id_dup");
goto done;
}
done:
if (tag)
got_object_tag_close(tag);
- if (err) {
- free(*commit_id);
- *commit_id = NULL;
- }
+ if (err == NULL)
+ *commit_id = obj_id;
+ else
+ free(obj_id);
return err;
}