Fix: use after free bug.
Fix: use after free bug.

These functions probably should also not be assert-failing on errors that
appear recoverable, but that is a debate for another day.

agacek/util_libs,agacek/util_libs,agacek/util_libs,agacek/util_libs