@@ -1817,7 +1817,7 @@ static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, int r
1817
1817
if (req_comp == img_n) return data;
1818
1818
STBI_ASSERT (req_comp >= 1 && req_comp <= 4 );
1819
1819
1820
- good = (stbi__uint16 *) stbi__malloc (req_comp * x * y * 2 );
1820
+ good = (stbi__uint16 *) stbi__malloc (( size_t ) req_comp * x * y * 2 );
1821
1821
if (good == NULL ) {
1822
1822
STBI_FREE (data);
1823
1823
return (stbi__uint16 *) stbi__errpuc (" outofmem" , " Out of memory" );
@@ -4821,7 +4821,7 @@ static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 r
4821
4821
stbi__create_png_alpha_expand8 (dest, dest, x, img_n);
4822
4822
} else if (depth == 8 ) {
4823
4823
if (img_n == out_n)
4824
- memcpy (dest, cur, x* img_n);
4824
+ memcpy (dest, cur, ( size_t )x * ( size_t ) img_n);
4825
4825
else
4826
4826
stbi__create_png_alpha_expand8 (dest, cur, x, img_n);
4827
4827
} else if (depth == 16 ) {
@@ -6201,7 +6201,7 @@ static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req
6201
6201
out = (stbi_uc *) stbi__malloc_mad3 (8 , w, h, 0 );
6202
6202
ri->bits_per_channel = 16 ;
6203
6203
} else
6204
- out = (stbi_uc *) stbi__malloc (4 * w* h);
6204
+ out = (stbi_uc *) stbi__malloc (4 * ( size_t )w * ( size_t ) h);
6205
6205
6206
6206
if (!out) return stbi__errpuc (" outofmem" , " Out of memory" );
6207
6207
pixelCount = w*h;
@@ -6524,7 +6524,7 @@ static void *stbi__pic_load(stbi__context *s,int *px,int *py,int *comp,int req_c
6524
6524
// intermediate buffer is RGBA
6525
6525
result = (stbi_uc *) stbi__malloc_mad3 (x, y, 4 , 0 );
6526
6526
if (!result) return stbi__errpuc (" outofmem" , " Out of memory" );
6527
- memset (result, 0xff , x*y* 4 );
6527
+ memset (result, 0xff , ( size_t )x * ( size_t )y * 4 );
6528
6528
6529
6529
if (!stbi__pic_load_core (s,x,y,comp, result)) {
6530
6530
STBI_FREE (result);
@@ -6833,11 +6833,11 @@ static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, i
6833
6833
}
6834
6834
6835
6835
// background is what out is after the undoing of the previou frame;
6836
- memcpy ( g->background , g->out , 4 * g->w * g->h );
6836
+ memcpy ( g->background , g->out , 4 * ( size_t ) g->w * ( size_t ) g->h );
6837
6837
}
6838
6838
6839
6839
// clear my history;
6840
- memset ( g->history , 0x00 , g->w * g->h ); // pixels that were affected previous frame
6840
+ memset ( g->history , 0x00 , ( size_t ) g->w * ( size_t ) g->h ); // pixels that were affected previous frame
6841
6841
6842
6842
for (;;) {
6843
6843
int tag = stbi__get8 (s);
@@ -6991,7 +6991,7 @@ static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y,
6991
6991
stride = g.w * g.h * 4 ;
6992
6992
6993
6993
if (out) {
6994
- void *tmp = (stbi_uc*) STBI_REALLOC_SIZED ( out, out_size, layers * stride );
6994
+ void *tmp = (stbi_uc*) STBI_REALLOC_SIZED ( out, out_size, ( size_t ) layers * ( size_t ) stride );
6995
6995
if (!tmp)
6996
6996
return stbi__load_gif_main_outofmem (&g, out, delays);
6997
6997
else {
@@ -7007,12 +7007,12 @@ static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y,
7007
7007
delays_size = layers * sizeof (int );
7008
7008
}
7009
7009
} else {
7010
- out = (stbi_uc*)stbi__malloc ( layers * stride );
7010
+ out = (stbi_uc*)stbi__malloc ( ( size_t ) layers * ( size_t ) stride );
7011
7011
if (!out)
7012
7012
return stbi__load_gif_main_outofmem (&g, out, delays);
7013
7013
out_size = layers * stride;
7014
7014
if (delays) {
7015
- *delays = (int *) stbi__malloc ( layers * sizeof (int ) );
7015
+ *delays = (int *) stbi__malloc ( ( size_t ) layers * sizeof (int ) );
7016
7016
if (!*delays)
7017
7017
return stbi__load_gif_main_outofmem (&g, out, delays);
7018
7018
delays_size = layers * sizeof (int );
0 commit comments