Skip to content

Commit d0c9724

Browse files
npt-1707hatstand
authored andcommitted
stb_image_aug: Reject fractional JPEG component subsampling ratios
1 parent 41bcdca commit d0c9724

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

3rdparty/libprojectm/Renderer/SOIL/stb_image_aug.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,13 @@ static int process_frame_header(jpeg *z, int scan)
12211221
if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v;
12221222
}
12231223

1224+
// check that plane subsampling factors are integer ratios; our resamplers can't deal with fractional ratios
1225+
// and I've never seen a non-corrupted JPEG file actually use them
1226+
for (i=0; i < s->img_n; ++i) {
1227+
if (h_max % z->img_comp[i].h != 0) return stbi__err("bad H","Corrupt JPEG");
1228+
if (v_max % z->img_comp[i].v != 0) return stbi__err("bad V","Corrupt JPEG");
1229+
}
1230+
12241231
// compute interleaved mcu info
12251232
z->img_h_max = h_max;
12261233
z->img_v_max = v_max;

0 commit comments

Comments
 (0)