diff --git a/app/utils/writer.c b/app/utils/writer.c index be811c66..3a1772e9 100644 --- a/app/utils/writer.c +++ b/app/utils/writer.c @@ -196,6 +196,11 @@ enum zsv_writer_status zsv_writer_delete(zsv_csv_writer w) { if (w->started) w->out.write("\n", 1, 1, w->out.stream); + if (w->out.stream && w->out.stream != stdout) { + fclose(w->out.stream); + w->out.stream = NULL; + } + if (w->out.buff) free(w->out.buff); free(w);