cppcheck: fix some memleaks