Fix double free and memory leak. (RhBug: 954294)