revert pull #2454
Merge pull request #2468 from WalterBright/revert2454

revert pull #2454
fix error identified by valgrind
Merge pull request #2471 from WalterBright/valgrind-fix

fix error identified by valgrind