Fixed few resource leak issues

Signed-off-by: Daan Hoogland <daan@onecht.net>
June14: Fixed few coverity issues reported

Signed-off-by: Daan Hoogland <daan@onecht.net>