clang: Use-after-free

Change-Id: I5dd857dbf39c8cd62df8b8cd0323b873a79976ae
(cherry picked from commit 112645f75816c4902ccf8a2a97ef57e8f13429b8)
Resolves: fdo#80160 PNG with 1-bit colormap only show black and white

Change-Id: If0c9950c18e6091fafea47954a4654db436a3a44
(cherry picked from commit 986c0451d05e7bb6ff7edd9f27d0e45532bcd22c)