fix leak
fix write on stack