[fix] Try to fix Ubuntu errors reported by valgrind