Fix places in public free() functions where NULL pointers aren't handled

Most existing public free() functions already handle this, but some don't. This PR addresses the remaining ones.

Note that this is useful for unconditionally freeing data when libgit2 returns an error, without having to worry about whether the error happened before or after an allocation libgit2 was going to do on behalf of the caller.