Skip to content

Commit

Permalink
fix: [stb_image_write.h] implicit conversions to larger type make exp…
Browse files Browse the repository at this point in the history
…licit via cast
  • Loading branch information
iWas-Coder committed Dec 3, 2024
1 parent d64d8d1 commit 24b9966
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions vendor/stb_image_write/stb_image_write.h
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ STBIWDEF int stbi_write_hdr(char const *filename, int x, int y, int comp, const
static void *stbiw__sbgrowf(void **arr, int increment, int itemsize)
{
int m = *arr ? 2*stbiw__sbm(*arr)+increment : increment+1;
void *p = STBIW_REALLOC_SIZED(*arr ? stbiw__sbraw(*arr) : 0, *arr ? (stbiw__sbm(*arr)*itemsize + sizeof(int)*2) : 0, itemsize * m + sizeof(int)*2);
void *p = STBIW_REALLOC_SIZED(*arr ? stbiw__sbraw(*arr) : 0, *arr ? (stbiw__sbm(*arr)*itemsize + sizeof(int)*2) : 0, (unsigned long) itemsize * m + sizeof(int)*2);
STBIW_ASSERT(p);
if (p) {
if (!*arr) ((int *) p)[1] = 0;
Expand Down Expand Up @@ -1112,7 +1112,7 @@ static void stbiw__encode_png_line(unsigned char *pixels, int stride_bytes, int
int signed_stride = stbi__flip_vertically_on_write ? -stride_bytes : stride_bytes;

if (type==0) {
memcpy(line_buffer, z, width*n);
memcpy(line_buffer, z, (size_t) width*n);
return;
}

Expand Down Expand Up @@ -1153,8 +1153,8 @@ STBIWDEF unsigned char *stbi_write_png_to_mem(const unsigned char *pixels, int s
force_filter = -1;
}

filt = (unsigned char *) STBIW_MALLOC((x*n+1) * y); if (!filt) return 0;
line_buffer = (signed char *) STBIW_MALLOC(x * n); if (!line_buffer) { STBIW_FREE(filt); return 0; }
filt = (unsigned char *) STBIW_MALLOC((size_t) (x*n+1) * y); if (!filt) return 0;
line_buffer = (signed char *) STBIW_MALLOC((size_t) x * n); if (!line_buffer) { STBIW_FREE(filt); return 0; }
for (j=0; j < y; ++j) {
int filter_type;
if (force_filter > -1) {
Expand Down Expand Up @@ -1182,7 +1182,7 @@ STBIWDEF unsigned char *stbi_write_png_to_mem(const unsigned char *pixels, int s
}
// when we get here, filter_type contains the filter type, and line_buffer contains the data
filt[j*(x*n+1)] = (unsigned char) filter_type;
STBIW_MEMMOVE(filt+j*(x*n+1)+1, line_buffer, x*n);
STBIW_MEMMOVE(filt+j*(x*n+1)+1, line_buffer, (size_t) x*n);
}
STBIW_FREE(line_buffer);
zlib = stbi_zlib_compress(filt, y*( x*n+1), &zlen, stbi_write_png_compression_level);
Expand Down

0 comments on commit 24b9966

Please sign in to comment.