Browse Source

ensure we consume stream when failing to read ICC profile

af/merge-core
Scott Williams 9 years ago
parent
commit
ee8f510e64
  1. 7
      src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs

7
src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs

@ -982,6 +982,7 @@ namespace ImageSharp.Formats
byte[] identifier = new byte[Icclength]; byte[] identifier = new byte[Icclength];
this.InputProcessor.ReadFull(identifier, 0, Icclength); this.InputProcessor.ReadFull(identifier, 0, Icclength);
remaining -= Icclength; // we have read it by this point
if (identifier[0] == 'I' && if (identifier[0] == 'I' &&
identifier[1] == 'C' && identifier[1] == 'C' &&
@ -996,7 +997,6 @@ namespace ImageSharp.Formats
identifier[10] == 'E' && identifier[10] == 'E' &&
identifier[11] == '\0') identifier[11] == '\0')
{ {
remaining -= Icclength;
byte[] profile = new byte[remaining]; byte[] profile = new byte[remaining];
this.InputProcessor.ReadFull(profile, 0, remaining); this.InputProcessor.ReadFull(profile, 0, remaining);
@ -1009,6 +1009,11 @@ namespace ImageSharp.Formats
metadata.IccProfile.Extend(profile); metadata.IccProfile.Extend(profile);
} }
} }
else
{
// not an ICC profile we can handle read the remaining so we can carry on and ignore this.
this.InputProcessor.Skip(remaining);
}
} }
/// <summary> /// <summary>

Loading…
Cancel
Save