alanrogers / legofit

Estimate population history parameters from site pattern frequencies.
Other
12 stars 1 forks source link

calloc logic problem #1

Closed mmcco closed 7 years ago

mmcco commented 7 years ago

I ran Clang's static analyzer on legofit and found a few minor issues. I'll open an issue for each.

This calloc(3) call appears on line 127 of boot.c:

self->count[i] = calloc((unsigned long) self->npat, sizeof(self->count[0]));

self->count is of type double **, so self->count[i] is of type double *. Therefore, if I understand correctly, the second argument of the calloc(3) call should be sizeof(double) or something equivalent. Currently, it is sizeof(double *).

alanrogers commented 7 years ago

I fixed this. The statement now reads:

    self->count[i] = calloc((unsigned long) self->npat,
                            sizeof(self->count[i][0]));