Skip to content

Commit

Permalink
Fix for CVE-2019-20056, assertion failure problem(#126). Thanks to @s…
Browse files Browse the repository at this point in the history
  • Loading branch information
saitoha committed Dec 30, 2019
1 parent 4fa442b commit bab1e60
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/stb_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -5045,13 +5045,13 @@ static int stbi__shiftsigned(int v, int shift, int bits)
static unsigned int shift_table[9] = {
0, 0,0,1,0,2,4,6,0,
};
if (bits < 0 || bits > 8) return (0); /* error */
if (shift < 0)
v <<= -shift;
else
v >>= shift;
STBI_ASSERT(v >= 0 && v < 256);
if (v >= 0 && v < 256) return (0);
v >>= (8-bits);
if (bits < 0 || bits > 8) return (0); /* error */
return (int) ((unsigned) v * mul_table[bits]) >> shift_table[bits];
}

Expand Down

0 comments on commit bab1e60

Please sign in to comment.