master: fix a couple of resource leaks

Reported by Coverity as CID #1141954