Skip to content

Commit

Permalink
Fix unprotected variable
Browse files Browse the repository at this point in the history
  • Loading branch information
stewid committed Apr 19, 2017
1 parent 7afb826 commit ffda908
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/git2r_repository.c
Expand Up @@ -499,6 +499,7 @@ SEXP git2r_repository_set_head_detached(SEXP commit)
*/
SEXP git2r_repository_workdir(SEXP repo)
{
int nprotect = 0;
SEXP result = R_NilValue;
git_repository *repository;

Expand All @@ -509,13 +510,14 @@ SEXP git2r_repository_workdir(SEXP repo)
if (!git_repository_is_bare(repository)) {
const char *wd = git_repository_workdir(repository);
PROTECT(result = allocVector(STRSXP, 1));
nprotect++;
SET_STRING_ELT(result, 0, mkChar(wd));
}

git_repository_free(repository);

if (!isNull(result))
UNPROTECT(1);
if (nprotect)
UNPROTECT(nprotect);

return result;
}
Expand Down

0 comments on commit ffda908

Please sign in to comment.