Assign result to var before freeing memory
Merge pull request #178 from musocrat/hotfix/segfaultpatch

Assign result to var before freeing memory