Commit bd0a5516 by Boris Egorov Committed by Carlos Martín Nieto

pathspec: do not try to dereference NULL

pathspec_match_free() should not dereference a NULL passed to it.

I found this issue when I tried to run example log program with
nonexistent branch:

./example/log help

Such call leads to segmentation fault.
parent 1ce9ea3b
...@@ -296,6 +296,9 @@ int git_pathspec_matches_path( ...@@ -296,6 +296,9 @@ int git_pathspec_matches_path(
static void pathspec_match_free(git_pathspec_match_list *m) static void pathspec_match_free(git_pathspec_match_list *m)
{ {
if (!m)
return;
git_pathspec_free(m->pathspec); git_pathspec_free(m->pathspec);
m->pathspec = NULL; m->pathspec = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment