fix copy-paste error
fix memory leak in error path
unused pointer value
Merge branch 'master' into portable