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>
commit0dfb177b481b22669e1a9a6aba183f3be4627108
parent2c2de560779e17f7d8800f8210512a5b97328237
authorEirik Aavitsland <eirik.aavitsland@qt.io>
committerEirik Aavitsland <eirik.aavitsland@qt.io>
commit timeMon, 5 Aug 2024 17:54:35 +0200