webp: Fix potential oob access and needless detach when storing image
The QImage to be stored was accessed with through a non-const copy in
write(), potentially causing a redundant detach. Worse, there was a
potential for taking the bytes-per-line value of the undetached image
and using that for the detached image (since the evaluation order of
function arguments is undefined). In case the original image had
non-standard amount of line padding (and the detached copy will have
standard amount), there was a risk of out-of-bounds memory access.
Fix by using const access instead to avoid detaching.
Fixes: QTBUG-127540
Pick-to: 6.8 6.7 6.5
Change-Id: I58e5ddae9850c79cb90298bfaf57d0203d346aee
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>