From aa838cd2aa5f9b8df03c221c6a50434388131651 Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" Date: Tue, 20 May 2025 09:57:17 -0400 Subject: [PATCH] allow files that have stuff after the image end chunk --- png.d | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/png.d b/png.d index 708c56b..5aa9f01 100644 --- a/png.d +++ b/png.d @@ -749,7 +749,7 @@ PNG* readPng(in ubyte[] data) { size_t pos = 8; - while(pos < data.length) { + while(pos < data.length && data.length - pos >= 12) { Chunk n; n.size |= data[pos++] << 24; n.size |= data[pos++] << 16; @@ -771,6 +771,9 @@ PNG* readPng(in ubyte[] data) { n.checksum |= data[pos++] << 0; p.chunks ~= n; + + if(n.type == "IEND") + break; } return p;