Fix memory leaks

3 jobs for issue/169 in 21 minutes and 5 seconds (queued for 1 second)
Status Job ID Name Coverage
  Build
passed mingw-build #440424

00:04:41

passed shared-build #440422

00:21:05

passed static-build #440423

00:19:00