--- bzr-1.12/bzrlib/_patiencediff_c.c.orig 2009-02-13 15:36:09.000000000 +0000 +++ bzr-1.12/bzrlib/_patiencediff_c.c 2009-02-18 08:59:32.000000000 +0000 @@ -461,7 +461,7 @@ last_b_pos = blo - 1; lcs = (struct matching_line *)malloc(sizeof(struct matching_line) * (bhi - blo)); - if (lcs == NULL) + if (lcs == NULL && (bhi - blo) != 0) return 0; lcs_size = unique_lcs(lcs, hashtable, backpointers, a, b, alo, blo, ahi, bhi); @@ -621,11 +621,11 @@ goto error; matches = (struct matching_line *)malloc(sizeof(struct matching_line) * bsize); - if (matches == NULL) + if (matches == NULL && bsize != 0) goto error; backpointers = (Py_ssize_t *)malloc(sizeof(Py_ssize_t) * bsize * 4); - if (backpointers == NULL) + if (backpointers == NULL && bsize != 0) goto error; nmatches = unique_lcs(matches, &hashtable, backpointers, a, b, 0, 0, asize, bsize); @@ -693,11 +693,11 @@ matches.count = 0; matches.matches = (struct matching_block *)malloc(sizeof(struct matching_block) * bsize); - if (matches.matches == NULL) + if (matches.matches == NULL && bsize != 0) goto error; backpointers = (Py_ssize_t *)malloc(sizeof(Py_ssize_t) * bsize * 4); - if (backpointers == NULL) + if (backpointers == NULL && bsize != 0) goto error; res = recurse_matches(&matches, &hashtable, backpointers, @@ -766,7 +766,7 @@ } self->backpointers = (Py_ssize_t *)malloc(sizeof(Py_ssize_t) * self->bsize * 4); - if (self->backpointers == NULL) { + if (self->backpointers == NULL && self->bsize != 0) { Py_DECREF(self); PyErr_NoMemory(); return NULL; @@ -813,7 +813,7 @@ matches.count = 0; matches.matches = (struct matching_block *)malloc(sizeof(struct matching_block) * self->bsize); - if (matches.matches == NULL) + if (matches.matches == NULL && self->bsize != 0) return PyErr_NoMemory(); res = recurse_matches(&matches, &self->hashtable, self->backpointers,