Fix mem leaks.
Merge remote-tracking branch 'origin/topic/jsiwek/coverity'

* origin/topic/jsiwek/coverity:
  Fix mem leaks.