diff --git a/src/ImageSharp/Formats/Jpeg/Port/JpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/Port/JpegDecoderCore.cs index 3d36d61d9..300cb7aef 100644 --- a/src/ImageSharp/Formats/Jpeg/Port/JpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/Port/JpegDecoderCore.cs @@ -362,26 +362,17 @@ namespace ImageSharp.Formats.Jpeg.Port codeLengthSum += codeLengths[j] = huffmanData[o++]; } + // TODO: Pooling? short[] huffmanValues = new short[codeLengthSum]; - - byte[] values = null; - try + using (var values = new Buffer(256)) { - values = ArrayPool.Shared.Rent(256); - this.InputStream.Read(values, 0, codeLengthSum); + this.InputStream.Read(values.Array, 0, codeLengthSum); for (int j = 0; j < codeLengthSum; j++) { huffmanValues[j] = values[o++]; } } - finally - { - if (values != null) - { - ArrayPool.Shared.Return(values); - } - } i += 17 + codeLengthSum;