Fix two use-after-free's and multiple memory leaks

10 jobs for master in 15 minutes and 35 seconds (queued for 15 seconds)
latest
Status Job ID Name Coverage
  Container Prep
passed #940691
arch:container_prep

00:05:58

passed #940690
debian:container_prep

00:04:48

 
  Build
passed #940694
arch:build-cmake

00:01:24

passed #940696
arch:build-meson

00:02:11

passed #940693
debian:build-cmake

00:01:58

passed #940695
debian:build-meson

00:01:10

passed #940692
format-and-spellcheck

00:00:43

 
  Pages
passed #940697
pages

00:00:25

 
  Deploy
passed pages:deploy

00:00:30

failed pages:deploy

00:00:01