comparison mercurial/bdiff.c @ 5571:f84bb2e1cc3a

fix calloc(0, ...) issue
author Jim Hague <jim.hague@acm.org>
date Tue, 23 Oct 2007 10:39:24 +0000
parents 82b4ff3abbcd
children 652f57de3ccf
comparison
equal deleted inserted replaced
5570:78a6b985882f 5571:f84bb2e1cc3a
243 struct pos *pos; 243 struct pos *pos;
244 int t; 244 int t;
245 245
246 /* allocate and fill arrays */ 246 /* allocate and fill arrays */
247 t = equatelines(a, an, b, bn); 247 t = equatelines(a, an, b, bn);
248 pos = (struct pos *)calloc(bn, sizeof(struct pos)); 248 pos = (struct pos *)calloc(bn ? bn : 1, sizeof(struct pos));
249 /* we can't have more matches than lines in the shorter file */ 249 /* we can't have more matches than lines in the shorter file */
250 l.head = l.base = (struct hunk *)malloc(sizeof(struct hunk) * 250 l.head = l.base = (struct hunk *)malloc(sizeof(struct hunk) *
251 ((an<bn ? an:bn) + 1)); 251 ((an<bn ? an:bn) + 1));
252 252
253 if (pos && l.base && t) { 253 if (pos && l.base && t) {