Fixed invalid free, discovered by scan-build
Merged Pull Request #368

* pull-request/368:
  Fixed invalid free, discovered by scan-build