Fixing control flow error (and a memory leak) found by coverity.  CID 26646
Merge pull request #2140 from tklein23/coverity_error_cid_26646

Fix control flow error (and a memory leak) found by coverity CID 26646