Fix some memleaks found by cppcheck. Anything broken?
(cherry picked from commit 2f06674d1141e754775ac552a2a2fa66c80b9b4c)

Conflicts:
	src/common/import_session.c