@@ -92,6 +92,29 @@ public void Decode_TruncatedPhysChunk_ExceptionIsThrown()
9292 Assert . Equal ( "pHYs chunk is too short" , exception . Message ) ;
9393 }
9494
95+ // https://github.com/SixLabors/ImageSharp/issues/3079
96+ [ Fact ]
97+ public void Decode_CompressedTxtChunk_WithTruncatedData_DoesNotThrow ( )
98+ {
99+ byte [ ] payload = [ 137 , 80 , 78 , 71 , 13 , 10 , 26 , 10 , // PNG signature
100+ 0 , 0 , 0 , 13 , // chunk length 13 bytes
101+ 73 , 72 , 68 , 82 , // chunk type IHDR
102+ 0 , 0 , 0 , 1 , 0 , 0 , 0 , 1 , 1 , 0 , 0 , 0 , 0 , // data
103+ 55 , 110 , 249 , 36 , // checksum
104+ 0 , 0 , 0 , 2 , // chunk length
105+ 122 , 84 , 88 , 116 , // chunk type zTXt
106+ 1 , 0 , // truncated data
107+ 100 , 138 , 166 , 20 , // crc
108+ 0 , 0 , 0 , 10 , // chunk length 10 bytes
109+ 73 , 68 , 65 , 84 , // chunk type IDAT
110+ 120 , 1 , 99 , 96 , 0 , 0 , 0 , 2 , 0 , 1 , // data
111+ 115 , 117 , 1 , 24 , // checksum
112+ 0 , 0 , 0 , 0 , 73 , 69 , 78 , 68 , 174 , 66 , 96 , 130 ] ; // end chunk
113+
114+ using MemoryStream stream = new ( payload ) ;
115+ using Image < Rgba32 > image = Image . Load < Rgba32 > ( stream ) ;
116+ }
117+
95118 private static string GetChunkTypeName ( uint value )
96119 {
97120 byte [ ] data = new byte [ 4 ] ;
0 commit comments