mangler: pkg free in case of errors