The vulnerability is an out-of-bounds read in the webp Rust crate, caused by a failure to validate input buffer sizes against the provided image dimensions. The root cause lies in the Encoder constructors (new, from_rgb, from_rgba), which allowed the creation of an Encoder instance with an invalid state (a buffer smaller than the size implied by width and height).
The actual memory corruption or information leak would occur when the encode or encode_advanced methods are called on this improperly configured Encoder instance. These methods would then pass the small buffer along with the large dimensions to the underlying libwebp C library, causing it to read beyond the buffer's bounds.
The patch addresses this by introducing a private, validated CheckedEncoder struct. The public Encoder constructors now delegate to CheckedEncoder::new, which performs the necessary bounds check and panics if the buffer is too small. This ensures that the encode_advanced function can only ever operate on validated, safe-to-use data, thus mitigating the vulnerability. The identified vulnerable functions include both the constructors where the invalid state is created and the encoding functions that trigger the unsafe operation, as both would be involved in a successful exploit.