Plug some leaks
Check the result of git_buf_joinpath
Added missing error handling path
Check for OOM