Added reset of pointer after memory free to avoid double-free crash