HPCC-9145 Fix some memory leaks

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Merge pull request #4270 from ghalliday/issue9145

HPCC-9145 Fix some memory leaks

Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>