Fixed memory leak of smartptr