From c196b5f2f8ee6d7d0e15683a25a788e9737d6152 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 23 Feb 2006 14:51:17 +0100 Subject: [PATCH] [PATCH] blktrace: fix possible crash on exit without ever opening an ofile --- blktrace.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/blktrace.c b/blktrace.c index 9aefac7..cac2c38 100644 --- a/blktrace.c +++ b/blktrace.c @@ -643,7 +643,7 @@ static void tip_ftrunc_final(struct thread_information *tip) /* * truncate to right size and cleanup mmap */ - if (tip->ofile_mmap) { + if (tip->ofile_mmap && tip->ofile) { int ofd = fileno(tip->ofile); if (tip->fs_buf) @@ -1382,7 +1382,8 @@ static void net_client_done(struct net_connection *nc) for (j = 0; j < nc->ncpus; j++) { tip = &dip->threads[j]; - fclose(tip->ofile); + if (tip->ofile) + fclose(tip->ofile); } free(dip->threads); -- 2.25.1