revparse: Free left side of invalid range revspecs This fixes a small memory leak in git_revparse where early returns on errors from git_revparse_single cause a free() on the (reallocated) left side of the revspec to be skipped.
diff --git a/src/revparse.c b/src/revparse.c
index d21f08b..2fdad00 100644
--- a/src/revparse.c
+++ b/src/revparse.c
@@ -912,13 +912,9 @@ int git_revparse(
rstr++;
}
- if ((error = git_revparse_single(&revspec->from, repo, lstr)) < 0) {
- return error;
- }
-
- if ((error = git_revparse_single(&revspec->to, repo, rstr)) < 0) {
- return error;
- }
+ error = git_revparse_single(&revspec->from, repo, lstr);
+ if (error == 0)
+ error = git_revparse_single(&revspec->to, repo, rstr);
git__free((void*)lstr);
} else {