A Type 3 font that is not an indirect object is refused during discovery, so the key mismatches and the write-back gaps it caused cannot arise. The pruned font /Resources goes into the font object instead of over a shared dictionary, prune_type3_from_resources counts the fonts child forms still draw, a form is scanned again in a different inherited context, the cleanup is skipped when only counting, and the surviving-references test no longer nests ifs.