Fix memory leak in occuring on error condition in reduction