diff --git a/thirdparty/stb_image/include/stb_image/stb_image.h b/thirdparty/stb_image/include/stb_image/stb_image.h index 86a4ae4..bdc93a3 100644 --- a/thirdparty/stb_image/include/stb_image/stb_image.h +++ b/thirdparty/stb_image/include/stb_image/stb_image.h @@ -3245,6 +3245,13 @@ static int stbi__process_frame_header(stbi__jpeg *z, int scan) if (z->img_comp[i].h > h_max) h_max = z->img_comp[i].h; if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v; } + + // check that plane subsampling factors are integer ratios; our resamplers can't deal with fractional ratios + // and I've never seen a non-corrupted JPEG file actually use them + for (i=0; i < s->img_n; ++i) { + if (h_max % z->img_comp[i].h != 0) return stbi__err("bad H","Corrupt JPEG"); + if (v_max % z->img_comp[i].v != 0) return stbi__err("bad V","Corrupt JPEG"); + } // compute interleaved mcu info z->img_h_max = h_max;