SixLabors / ImageSharp

:camera: A modern, cross-platform, 2D Graphics library for .NET
https://sixlabors.com/products/imagesharp/
Other
7.34k stars 847 forks source link

Fix #2779 buffer overrun #2780

Closed KirillAldashkin closed 1 month ago

KirillAldashkin commented 1 month ago

Prerequisites

Description

Fix #2779 by accounting pixel size. Also fixed some width*height multuplication overflows:

using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;

Rgba64[] data = new Rgba64[65536];
using Image<Rgba64> img = Image.WrapMemory<Rgba64>(data, 65537, 65536);
// doesn't throw here but will blow up later

// ...here for example
img.SaveAsPng("output.png");
CLAassistant commented 1 month ago

CLA assistant check
All committers have signed the CLA.