Fixed cpp check warnings: memory leak and uninitialized vars