Fix several memory leaks.

Signed-off-by: David Navarro <david.navarro@intel.com>