master: fix a resource leak

Reported by Coverity as CID #1141954