diff --git a/src/terminal/stb_image.h b/src/terminal/stb_image.h index 9eedabedc..90159ff2c 100644 --- a/src/terminal/stb_image.h +++ b/src/terminal/stb_image.h @@ -1226,6 +1226,9 @@ static void stbi__vertical_flip(void *image, int w, int h, int bytes_per_pixel) stbi_uc temp[2048]; stbi_uc *bytes = (stbi_uc *)image; + if (w <= 0 || bytes_per_pixel <= 0 || bytes_per_row / (size_t)bytes_per_pixel != (size_t)w) + return; + for (row = 0; row < (h>>1); row++) { stbi_uc *row0 = bytes + row*bytes_per_row; stbi_uc *row1 = bytes + (h - row - 1)*bytes_per_row;