diff options
author | Jaroslav Škarvada <jskarvad@redhat.com> | 2012-11-28 16:42:41 +0100 |
---|---|---|
committer | Chris E Ferron <chris.e.ferron@linux.intel.com> | 2012-11-29 07:55:47 -0800 |
commit | 134a67c1051e9c640ccbc396665a9a875f93defd (patch) | |
tree | bdeaf60f720eab6a85d1c31771d1c1e5ebcf1d71 | |
parent | 78956bdcd91c1e1c49e0462b64dda9c11a8ae53d (diff) | |
download | powertop-2.0-v2-134a67c1051e9c640ccbc396665a9a875f93defd.tar.gz |
report: fixed crash when writing report to RO filesystem
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
-rw-r--r-- | src/report/report.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/report/report.cpp b/src/report/report.cpp index 51bc6a7..c018bb1 100644 --- a/src/report/report.cpp +++ b/src/report/report.cpp @@ -183,13 +183,16 @@ void init_report_output(char *filename_str, int iterations) void finish_report_output(void) { - fprintf(stderr, _("PowerTOP outputing using base filename %s\n"), reportout.filename); if (reporttype == REPORT_OFF) return; report.finish_report(); - fputs(report.get_result(), reportout.report_file); - fdatasync(fileno(reportout.report_file)); - fclose(reportout.report_file); + if (reportout.report_file) + { + fprintf(stderr, _("PowerTOP outputing using base filename %s\n"), reportout.filename); + fputs(report.get_result(), reportout.report_file); + fdatasync(fileno(reportout.report_file)); + fclose(reportout.report_file); + } report.clear_result(); } |