Android security tags, read closely by Lightrion

CVE-2026-58936 AI-generated analysis

platform/external/libpng, tRNS/PLTE storage (pngset.c), read/write struct teardown (pngread.c, pngwrite.c), read transforms (pngrtran.c)

AI-generated: written from the bulletin and the fixing diffs by claude-fable-5-1, then checked against the code by claude-opus-5-5 (5 corrections). Verify against the commit before relying on it.

Gives png_struct its own heap copies of the tRNS alpha array and the PLTE palette instead of aliasing the buffers owned by png_info, so that freeing them through info_ptr (png_free_data or a repeated png_set_tRNS/png_set_PLTE) no longer leaves png_ptr->trans_alpha / png_ptr->palette dangling for the row transform code.

Root cause

In pngset.c, png_set_tRNS ended with `png_ptr->trans_alpha = info_ptr->trans_alpha;` and png_set_PLTE assigned `info_ptr->palette = png_ptr->palette;`, so png_struct and png_info pointed at the same heap buffer. When the buffer was freed through info_ptr, either by png_free_data(PNG_FREE_TRNS/PNG_FREE_PLTE) or by the png_free_data call at the start of a second png_set_tRNS/png_set_PLTE, png_ptr kept the stale pointer. Before the fix, png_read_destroy freed png_ptr's copy only when png_ptr->free_me had the matching bit set. Per the commit messages, row transforms such as png_do_expand_palette then read freed memory, and the palette bit-shift path wrote to it (the code context shows in-place writes to png_ptr->palette[i] in the READ_SHIFT block). A TODO in png_handle_tRNS ("horrible side effect ... Fix this.") documented the aliasing. png_set_quantize also stored the caller's raw palette pointer into png_ptr->palette, which would have made an unconditional free in png_read_destroy unsafe.

How the fix works

Completeness

Behavior changes

Per major

Unknowns

Back to November 2026 · Findings