fix copy-paste error
fix memory leak in error path
unused pointer value