Fixes memory leak in stats.c in failure cases.