Fix some coverity-found issues
Merge pull request #2287 from libgit2/rb/moar-coverity-fixes

Fix some issues from the last Coverity scan