@@ -1817,7 +1817,7 @@ static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, int r
18171817 if (req_comp == img_n) return data;
18181818 STBI_ASSERT (req_comp >= 1 && req_comp <= 4 );
18191819
1820- good = (stbi__uint16 *) stbi__malloc (req_comp * x * y * 2 );
1820+ good = (stbi__uint16 *) stbi__malloc (( size_t ) req_comp * x * y * 2 );
18211821 if (good == NULL ) {
18221822 STBI_FREE (data);
18231823 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
48214821 stbi__create_png_alpha_expand8 (dest, dest, x, img_n);
48224822 } else if (depth == 8 ) {
48234823 if (img_n == out_n)
4824- memcpy (dest, cur, x* img_n);
4824+ memcpy (dest, cur, ( size_t )x * ( size_t ) img_n);
48254825 else
48264826 stbi__create_png_alpha_expand8 (dest, cur, x, img_n);
48274827 } else if (depth == 16 ) {
@@ -6201,7 +6201,7 @@ static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req
62016201 out = (stbi_uc *) stbi__malloc_mad3 (8 , w, h, 0 );
62026202 ri->bits_per_channel = 16 ;
62036203 } else
6204- out = (stbi_uc *) stbi__malloc (4 * w* h);
6204+ out = (stbi_uc *) stbi__malloc (4 * ( size_t )w * ( size_t ) h);
62056205
62066206 if (!out) return stbi__errpuc (" outofmem" , " Out of memory" );
62076207 pixelCount = w*h;
@@ -6524,7 +6524,7 @@ static void *stbi__pic_load(stbi__context *s,int *px,int *py,int *comp,int req_c
65246524 // intermediate buffer is RGBA
65256525 result = (stbi_uc *) stbi__malloc_mad3 (x, y, 4 , 0 );
65266526 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 );
65286528
65296529 if (!stbi__pic_load_core (s,x,y,comp, result)) {
65306530 STBI_FREE (result);
@@ -6833,11 +6833,11 @@ static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, i
68336833 }
68346834
68356835 // 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 );
68376837 }
68386838
68396839 // 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
68416841
68426842 for (;;) {
68436843 int tag = stbi__get8 (s);
@@ -6991,7 +6991,7 @@ static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y,
69916991 stride = g.w * g.h * 4 ;
69926992
69936993 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 );
69956995 if (!tmp)
69966996 return stbi__load_gif_main_outofmem (&g, out, delays);
69976997 else {
@@ -7007,12 +7007,12 @@ static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y,
70077007 delays_size = layers * sizeof (int );
70087008 }
70097009 } else {
7010- out = (stbi_uc*)stbi__malloc ( layers * stride );
7010+ out = (stbi_uc*)stbi__malloc ( ( size_t ) layers * ( size_t ) stride );
70117011 if (!out)
70127012 return stbi__load_gif_main_outofmem (&g, out, delays);
70137013 out_size = layers * stride;
70147014 if (delays) {
7015- *delays = (int *) stbi__malloc ( layers * sizeof (int ) );
7015+ *delays = (int *) stbi__malloc ( ( size_t ) layers * sizeof (int ) );
70167016 if (!*delays)
70177017 return stbi__load_gif_main_outofmem (&g, out, delays);
70187018 delays_size = layers * sizeof (int );
0 commit comments