Fix out-of-band deref of (potentially) gone threads structure
[fio.git] / log.c
diff --git a/log.c b/log.c
index 15de3c24d10bf64698325479af7e5b45f80c81aa..8f92e93f065d7b57234bbdbccf8bab875f785fe9 100644 (file)
--- a/log.c
+++ b/log.c
@@ -40,6 +40,13 @@ void log_file(struct thread_data *td, struct fio_file *f,
        if (!td->o.write_iolog_file)
                return;
 
+
+       /*
+        * this happens on the pre-open/close done before the job starts
+        */
+       if (!td->iolog_f)
+               return;
+
        fprintf(td->iolog_f, "%s %s\n", f->file_name, act[what]);
 }
 
@@ -465,8 +472,9 @@ void __finish_log(struct io_log *log, const char *name)
 
 void finish_log(struct thread_data *td, struct io_log *log, const char *name)
 {
-       char file_name[256];
+       char file_name[256], *p;
 
        snprintf(file_name, 200, "%s_%s.log", td->o.name, name);
-       __finish_log(log, file_name);
+       p = basename(file_name);
+       __finish_log(log, p);
 }