fix crash if out of memory (found by cppcheck)

pull/324/head
Philipp Wiesemann 2016-06-15 23:13:55 +02:00
parent c9ead07188
commit 01c95ca994
1 changed files with 1 additions and 1 deletions

View File

@ -4351,7 +4351,7 @@ static int stbi__reduce_png(stbi__png *p)
if (p->depth != 16) return 1; // don't need to do anything if not 16-bit data
reduced = (stbi_uc *)stbi__malloc(img_len);
if (p == NULL) return stbi__err("outofmem", "Out of memory");
if (reduced == NULL) return stbi__err("outofmem", "Out of memory");
for (i = 0; i < img_len; ++i) reduced[i] = (stbi_uc)((orig[i] >> 8) & 0xFF); // top half of each byte is a decent approx of 16->8 bit scaling