fix memory leak
Merge branch 'master' into portable