misc: Fixes and workarounds for UAF warnings. (GCC12)

The mscoree one is a genuine UAF bug, other are more arguably false positive but GCC doesn't like freed pointer value to be used in any way.

Merge request reports

Loading