From 2219a6da29b978e783ff0d155433ec95eedd56ce Mon Sep 17 00:00:00 2001 From: Jeremy Sawicki Date: Fri, 3 Mar 2017 00:13:27 -0800 Subject: [PATCH] stb_image: JPEG: Accept DNL segment --- stb_image.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/stb_image.h b/stb_image.h index 3940f38..705f87a 100644 --- a/stb_image.h +++ b/stb_image.h @@ -3129,6 +3129,11 @@ static int stbi__decode_jpeg_image(stbi__jpeg *j) } // if we reach eof without hitting a marker, stbi__get_marker() below will fail and we'll eventually return 0 } + } else if (stbi__DNL(m)) { + int Ld = stbi__get16be(j->s); + stbi__uint32 NL = stbi__get16be(j->s); + if (Ld != 4) stbi__err("bad DNL len", "Corrupt JPEG"); + if (NL != j->s->img_y) stbi__err("bad DNL height", "Corrupt JPEG"); } else { if (!stbi__process_marker(j, m)) return 0; }