fix double ptr and use zfree