diff options
author | yorah <yoram.harmelin@gmail.com> | 2013-07-03 17:07:20 +0200 |
---|---|---|
committer | yorah <yoram.harmelin@gmail.com> | 2013-07-03 17:22:12 +0200 |
commit | 9b6075b25fb6fef570dd29c2b797db8bc34cf0b1 (patch) | |
tree | 18f3b3e105345b0dcc9c9a99447a24c6a3af3a4e /src | |
parent | 6bb7bff274be004768ccedf76643383494e2a9dc (diff) | |
download | libgit2-9b6075b25fb6fef570dd29c2b797db8bc34cf0b1.tar.gz |
Fix segfault in git_status_foreach_ext()
Add tests for the `GIT_STATUS_SHOW_XXX` flags.
Diffstat (limited to 'src')
-rw-r--r-- | src/diff.c | 2 | ||||
-rw-r--r-- | src/status.c | 12 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/diff.c b/src/diff.c index 26e117402..9e9528ef9 100644 --- a/src/diff.c +++ b/src/diff.c @@ -1273,7 +1273,7 @@ int git_diff__paired_foreach( git_vector_sort(&idx2wd->deltas); } } - else if (head2idx->opts.flags & GIT_DIFF_DELTAS_ARE_ICASE) + else if (head2idx != NULL && head2idx->opts.flags & GIT_DIFF_DELTAS_ARE_ICASE) strcomp = git__strcasecmp; for (i = 0, j = 0; i < i_max || j < j_max; ) { diff --git a/src/status.c b/src/status.c index e520c1017..7da94edc1 100644 --- a/src/status.c +++ b/src/status.c @@ -257,6 +257,7 @@ int git_status_list_new( opts ? opts->show : GIT_STATUS_SHOW_INDEX_AND_WORKDIR; int error = 0; unsigned int flags = opts ? opts->flags : GIT_STATUS_OPT_DEFAULTS; + git_diff_list *head2idx = NULL; assert(show <= GIT_STATUS_SHOW_INDEX_THEN_WORKDIR); @@ -307,8 +308,10 @@ int git_status_list_new( &status->head2idx, repo, head, NULL, &diffopt)) < 0) goto done; + head2idx = status->head2idx; + if ((flags & GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX) != 0 && - (error = git_diff_find_similar(status->head2idx, NULL)) < 0) + (error = git_diff_find_similar(head2idx, NULL)) < 0) goto done; } @@ -324,15 +327,14 @@ int git_status_list_new( if (show == GIT_STATUS_SHOW_INDEX_THEN_WORKDIR) { if ((error = git_diff__paired_foreach( - status->head2idx, NULL, status_collect, status)) < 0) + head2idx, NULL, status_collect, status)) < 0) goto done; - git_diff_list_free(status->head2idx); - status->head2idx = NULL; + head2idx = NULL; } if ((error = git_diff__paired_foreach( - status->head2idx, status->idx2wd, status_collect, status)) < 0) + head2idx, status->idx2wd, status_collect, status)) < 0) goto done; if (flags & GIT_STATUS_OPT_SORT_CASE_SENSITIVELY) |