X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=diff.c;h=d8d20c2fcb141124bf4c798eb054e5c1be451f68;hb=b93aa3ec9506618e9a22c04d775b35f31e7e068f;hp=1059049fb99ae45fcfb81f3bf9ebb19005c67561;hpb=705a7148ba1bb9597b1837b7f64a0dcb67f1ad0c;p=git.git diff --git a/diff.c b/diff.c index 1059049f..d8d20c2f 100644 --- a/diff.c +++ b/diff.c @@ -402,13 +402,14 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only) return 0; } -void diff_free_filespec(struct diff_filespec *s) +void diff_free_filespec_data(struct diff_filespec *s) { if (s->should_free) free(s->data); else if (s->should_munmap) munmap(s->data, s->size); - free(s); + s->should_free = s->should_munmap = 0; + s->data = NULL; } static void prep_temp_blob(struct diff_tempfile *temp, @@ -761,14 +762,17 @@ struct diff_filepair *diff_queue(struct diff_queue_struct *queue, dp->status = 0; dp->source_stays = 0; dp->broken_pair = 0; - diff_q(queue, dp); + if (queue) + diff_q(queue, dp); return dp; } void diff_free_filepair(struct diff_filepair *p) { - diff_free_filespec(p->one); - diff_free_filespec(p->two); + diff_free_filespec_data(p->one); + diff_free_filespec_data(p->two); + free(p->one); + free(p->two); free(p); }