ecc: Free memory also when in error branch.