summaryrefslogtreecommitdiff
path: root/src/revparse.c
diff options
context:
space:
mode:
authorVicent Martí <vicent@github.com>2012-06-19 09:27:40 -0700
committerVicent Martí <vicent@github.com>2012-06-19 09:27:40 -0700
commit1b0ef5aa03fad68105784d5d4d87592ce005e03a (patch)
treed74f6f5632939d0e6336f671751168a0ab5c79f4 /src/revparse.c
parent68f527c4480f0c1e24f29dc0a2337469fe50967f (diff)
parent2c90145aad86084dc72400ad0d47ed6e0ce2762f (diff)
downloadlibgit2-1b0ef5aa03fad68105784d5d4d87592ce005e03a.tar.gz
Merge pull request #774 from benstraub/revparse-colon-segfault
Fix potential segfault in revparse.
Diffstat (limited to 'src/revparse.c')
-rw-r--r--src/revparse.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/revparse.c b/src/revparse.c
index 4d6ffb56e..0c053b397 100644
--- a/src/revparse.c
+++ b/src/revparse.c
@@ -406,7 +406,7 @@ static int handle_caret_syntax(git_object **out, git_repository *repo, git_objec
*out = newobj2;
return 0;
}
-
+
/* {/...} -> Walk all commits until we see a commit msg that matches the phrase. */
if (movement[1] == '/') {
int retcode = GIT_ERROR;
@@ -550,6 +550,11 @@ static int oid_for_tree_path(git_oid *out, git_tree *tree, git_repository *repo,
}
}
+ if (!entry) {
+ giterr_set(GITERR_INVALID, "Invalid tree path '%s'", path);
+ return GIT_ERROR;
+ }
+
git_oid_cpy(out, git_tree_entry_id(entry));
git__free(alloc);
return 0;