HPCC-10876 Fix various issues highlighted by coverity scan

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
HPCC-10876 Modifications following code review.

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

HPCC-10876 Fix various issues highlighted by coverity scan

Reviewed-By: Jamie Noss <james.noss@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>