Skip to content

Remove header size check for WebP images

What is going wrong

!6 (merged) was supposed to fix BUG 461635, but it wasn't on my machine despite having the patch applied. After doing some digging, I figured out the root of the issue. There's a check that requires that QIODevice::bytesAvailable() matches the file size reported by the WebP header, but this thinking is inherently flawed because Qt network IO objects typically return the default IO buffer size and don't read everything until QIODevice::readAll() is called. This is true, and doing some print debugging shows bytesAvailable() returning 16384 which means this patch only fixed smaller WebP images, bigger ones will fail.

What is the consequences of removing the check?

I'm not sure but I'm pretty sure it would be fine, because if we move the check instead of outright removing it (like placing it after readAll() is called) I don't know the point of it anymore. Surely libwebp will handle malformed WebP better than we can, and simply error out during read().

Merge request reports