From fd8470af2af3310d78c72dfdcfe27ab2b0507e24 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 11 Nov 2008 23:07:36 +0000 Subject: [PATCH] - client: don't fclose() time_stats_log if it's NULL Fixes #772 svn path=/trunk/boinc/; revision=16478 --- checkin_notes | 9 +++++++++ client/time_stats.cpp | 4 +++- lib/parse.cpp | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/checkin_notes b/checkin_notes index 7ce35acd80..59c3aaaad4 100644 --- a/checkin_notes +++ b/checkin_notes @@ -9360,3 +9360,12 @@ Charlie 10 Nov 2008 (checked into boinc_core_release_6_3_22 tag) AsyncRPC.cpp DlgExitMessage.cpp DlgOptions.cpp + +David 11 Nov 2008 + - client: don't fclose() time_stats_log if it's NULL + Fixes #772 + + client/ + time_stats.cpp + lib/ + parse.cpp diff --git a/client/time_stats.cpp b/client/time_stats.cpp index 7ff0a11791..acf5c80af8 100644 --- a/client/time_stats.cpp +++ b/client/time_stats.cpp @@ -138,7 +138,9 @@ void send_log_after(const char* filename, double t, MIOFILE& mf) { // copy the log file after a given time // void TIME_STATS::get_log_after(double t, MIOFILE& mf) { - fclose(time_stats_log); // win: can't open twice + if (time_stats_log) { + fclose(time_stats_log); // win: can't open twice + } send_log_after(TIME_STATS_LOG, t, mf); time_stats_log = fopen(TIME_STATS_LOG, "a"); } diff --git a/lib/parse.cpp b/lib/parse.cpp index eed794b1f7..7cb558699b 100644 --- a/lib/parse.cpp +++ b/lib/parse.cpp @@ -155,6 +155,9 @@ int dup_element_contents(FILE* in, const char* end_tag, char** pp) { int nused=0; // not counting ending NULL char* buf = (char*)malloc(bufsize); + // Start with a big buffer. + // When done, copy to an exact-size buffer + // while (fgets(line, 256, in)) { if (strstr(line, end_tag)) { *pp = (char*)malloc(nused+1);