fix segment bug,error pointer better initialize to NULL