Ticket 47772 - fix coverity issue

12565 - resource leak
12564 - Explicit null dereferenced

https://fedorahosted.org/389/ticket/47772

Reviewed by: rmeggins(Thanks!)

(cherry picked from commit 24d44ba65398470fc8056b14b77b34b5d660f34e)