diff --git a/MetadataExtractor/Formats/Png/PngMetadataReader.cs b/MetadataExtractor/Formats/Png/PngMetadataReader.cs index ad4ecb46c..4601fbc9f 100644 --- a/MetadataExtractor/Formats/Png/PngMetadataReader.cs +++ b/MetadataExtractor/Formats/Png/PngMetadataReader.cs @@ -264,7 +264,9 @@ private static IEnumerable ProcessChunk(PngChunk chunk) { if (compressionMethod == 0) { - if (!TryDeflate(bytes, bytesLeft, out textBytes, out string? errorMessage)) + reader.Skip(2); // Skip over the zlib header bytes (78 9C) + bytesLeft -= 2; + if (!TryDeflate(reader.GetBytes(bytesLeft), bytesLeft, out textBytes, out string? errorMessage)) { var directory = new PngDirectory(PngChunkType.iTXt); directory.AddError($"Exception decompressing PNG {nameof(PngChunkType.iTXt)} chunk with keyword \"{keyword}\": {errorMessage}");