Fix pointer-to-local-leaves-scope issue

Found by coverity