Yes, everything that is allocated on the heap will be leaking. What we usually do is define a `cleanup` or `error` label that contains all the cleanup steps, and `goto` there if a libgit2 call returns an error.