From b63b3b0e4df81174a323ff6b1b4450014502e9b7 Mon Sep 17 00:00:00 2001 From: Jacques Germishuys Date: Sun, 25 Jan 2015 14:08:05 +0200 Subject: [PATCH 1/3] Ensure git_index_entry is not NULL before trying to free it --- src/index.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/index.c b/src/index.c index 079b0cb65..cbace3606 100644 --- a/src/index.c +++ b/src/index.c @@ -292,6 +292,9 @@ static void index_entry_reuc_free(git_index_reuc_entry *reuc) static void index_entry_free(git_index_entry *entry) { + if (!entry) + return; + memset(&entry->id, 0, sizeof(entry->id)); git__free(entry); } From 636af2198e7d9128d6bf49cd7f7119de62fd5975 Mon Sep 17 00:00:00 2001 From: Jacques Germishuys Date: Sun, 25 Jan 2015 14:38:10 +0200 Subject: [PATCH 2/3] Return early if allocating a git_pathspec_match_list failed --- src/pathspec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pathspec.c b/src/pathspec.c index 8b469f717..97b5d94dc 100644 --- a/src/pathspec.c +++ b/src/pathspec.c @@ -315,6 +315,9 @@ static git_pathspec_match_list *pathspec_match_alloc( m = NULL; } + if (!m) + return NULL; + /* need to keep reference to pathspec and increment refcount because * failures array stores pointers to the pattern strings of the * pathspec that had no matches From bb6aafe88f01d2902085fd78464ae277ebea0a67 Mon Sep 17 00:00:00 2001 From: Jacques Germishuys Date: Sun, 25 Jan 2015 14:40:23 +0200 Subject: [PATCH 3/3] Ensure the diff hunk callback is specified before trying to dereference it --- src/diff_patch.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/diff_patch.c b/src/diff_patch.c index 3129d06e1..a15107753 100644 --- a/src/diff_patch.c +++ b/src/diff_patch.c @@ -823,7 +823,8 @@ int git_patch__invoke_callbacks( for (i = 0; !error && i < git_array_size(patch->hunks); ++i) { diff_patch_hunk *h = git_array_get(patch->hunks, i); - error = hunk_cb(patch->delta, &h->hunk, payload); + if (hunk_cb) + error = hunk_cb(patch->delta, &h->hunk, payload); if (!line_cb) continue;