astromatic / swarp

resample and coadd FITS images to an arbitrary astrometric projection
https://astromatic.net/software/swarp
GNU General Public License v3.0
31 stars 5 forks source link

int * int multiplication prior to promotion to size_t causes error #14

Closed EricTittley closed 4 months ago

EricTittley commented 4 months ago

fits/fitsbody.chas the line:

npix = tab->naxisn[0] * tab->naxisn[1]; That's size_t = int * int

If int * int is greater than INT_MAX (2147483647 = 2.1G) than the result is garbage.

Easy fix, just force the promotion with casts: npix = (size_t)tab->naxisn[0] * (size_t)tab->naxisn[1];

I've had to implement this for local users with large survey images. Best to make the change in the original source.

ebertin commented 4 months ago

Thanks for the heads up! A classic one!