small changes to code safety issue that's detected by cppcheck.