fix seg fault by using strdup