Skip to content

Commit

Permalink
stb_image: fix for #76 POC h050. detect bad PSD file.
Browse files Browse the repository at this point in the history
  • Loading branch information
saitoha committed Aug 5, 2018
1 parent d7b2600 commit 197d025
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/stb_image.h
Expand Up @@ -5842,11 +5842,15 @@ static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req
} else {
stbi_uc *p = out+channel;
if (bitdepth == 16) { // input bpc
for (i = 0; i < pixelCount; i++, p += 4)
for (i = 0; i < pixelCount; i++, p += 4) {
if (stbi__at_eof(s)) return stbi__errpuc("bad file","PSD file too short");
*p = (stbi_uc) (stbi__get16be(s) >> 8);
}
} else {
for (i = 0; i < pixelCount; i++, p += 4)
for (i = 0; i < pixelCount; i++, p += 4) {
if (stbi__at_eof(s)) return stbi__errpuc("bad file","PSD file too short");
*p = stbi__get8(s);
}
}
}
}
Expand Down

0 comments on commit 197d025

Please sign in to comment.