core/rpc: avoid double close

Reported by coverity as CID #1231253
plugins/rpc: fix a couple of memory leaks

Always free response, in the worst case we are freeing NULL which
is a NOP.
Reported by Coverity as CID #1231246, #1231245
Merge pull request #688 from xrmx/coverity1608

Few coverity fixes