go-libjpeg icon indicating copy to clipboard operation
go-libjpeg copied to clipboard

YCbCr 4:2:0 reads from out of bounds memory

Open fzwoch opened this issue 2 years ago • 0 comments

During encoding I think YCbCr 4:2.0 may read from locations of the Cb and Cr planes that are out of bounds.

I also think it happens when the image width/height is not a multiple of 16 (8?).

E.g. 1280x720 is fine while 1920x1080 is not (8 pixel rows missing for being multiple of 16).

Primarily manifests itself on Windows platform. It seems to crash here quite reliably while on Linux and macOS it accepts the read (may be just a random factor).

One can work around it by over-allocating the YCbCr image buffers, but it is not obvious to the user, but I'm also unsure what actually happens with the bogus data that is then read (does it corrupt the originally expected image data?).

fzwoch avatar Jan 04 '22 08:01 fzwoch