From dc5fe00c6562e46c88a5c5b975121c202eae1180 Mon Sep 17 00:00:00 2001 From: Boris Egorov Date: Sun, 25 Jan 2015 00:07:23 +0600 Subject: [PATCH] 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. --- src/pathspec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pathspec.c b/src/pathspec.c index 8b469f717..6aef574c8 100644 --- a/src/pathspec.c +++ b/src/pathspec.c @@ -296,6 +296,9 @@ int git_pathspec_matches_path( static void pathspec_match_free(git_pathspec_match_list *m) { + if (!m) + return; + git_pathspec_free(m->pathspec); m->pathspec = NULL;