Skip to content

Commit

Permalink
Updated STB image
Browse files Browse the repository at this point in the history
  • Loading branch information
dfeneyrou committed Nov 26, 2021
1 parent cd29e87 commit fd14c6e
Show file tree
Hide file tree
Showing 2 changed files with 1,733 additions and 2 deletions.
11 changes: 9 additions & 2 deletions server/external/stb_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ static int stbi__mad3sizes_valid(int a, int b, int c, int add)
}

// returns 1 if "a*b*c*d + add" has no negative terms/factors and doesn't overflow
#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR)
#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) || !defined(STBI_NO_PNM)
static int stbi__mad4sizes_valid(int a, int b, int c, int d, int add)
{
return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) &&
Expand All @@ -1055,7 +1055,7 @@ static void *stbi__malloc_mad3(int a, int b, int c, int add)
return stbi__malloc(a*b*c + add);
}

#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR)
#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) || !defined(STBI_NO_PNM)
static void *stbi__malloc_mad4(int a, int b, int c, int d, int add)
{
if (!stbi__mad4sizes_valid(a, b, c, d, add)) return NULL;
Expand Down Expand Up @@ -3267,6 +3267,13 @@ static int stbi__process_frame_header(stbi__jpeg *z, int scan)
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;
z->img_v_max = v_max;
Expand Down
Loading

0 comments on commit fd14c6e

Please sign in to comment.