HPCC-10844 Fix some memory leaks in the code generator

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

HPCC-10844 Fix some memory leaks in the code generator

Reviewed-By: Jamie Noss <james.noss@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>