fix: Handle self-referencing pointers in getter-to-setter aliasing

Apply a robustness fix for a caller-side API usage pattern involving
the getters and the setters for PLTE, tRNS, and hIST.

Passing a pointer returned by the PLTE, tRNS, or hIST getters back
into the corresponding setters used to cause the setters to read from
a stale pointer. The fix consists in snapshotting the caller's data
into a stack-local buffer before freeing the old internal storage.

Fixes pnggroup/libpng#836

Reported-by: Iv4n <Iv4n550@noreply.github.com>
5 files changed