From d87320e7ff2e96a5224664e7c13130f51d0d1010 Mon Sep 17 00:00:00 2001 From: cora32 Date: Sun, 9 Aug 2015 03:32:59 +0300 Subject: [PATCH] Descriptors leak fix. --- finder.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/finder.cpp b/finder.cpp index 26ca181..c55e5ae 100644 --- a/finder.cpp +++ b/finder.cpp @@ -2564,7 +2564,8 @@ void parseFlag(int flag, char* ip, int port, int size, const std::string &header date, date, Utils::getStartTime().c_str()); char string[1024] = { 0 }; - if (fopen(fileName, "r") == NULL) { + FILE *fc = fopen(fileName, "r"); + if (fc == NULL) { FILE *f = fopen(fileName, "a"); if (f != NULL) { sprintf(string, RVI_START_FILE"\n\t\n\n", @@ -2572,9 +2573,9 @@ void parseFlag(int flag, char* ip, int port, int size, const std::string &header fputs(string, f); fclose(f); } - else stt->doEmitionRedFoundData("Cannot open xml - \"" + QString::fromLocal8Bit(fileName)); - } - else { + else stt->doEmitionRedFoundData("Cannot open xml - \"" + QString::fromLocal8Bit(fileName) + " Err:" + QString::number(GetLastError())); + } else { + fclose(fc); FILE *f = fopen(fileName, "r+"); if (f != NULL) { fseek(f, -35, SEEK_END); @@ -2583,7 +2584,7 @@ void parseFlag(int flag, char* ip, int port, int size, const std::string &header fputs(string, f); fclose(f); } - else stt->doEmitionRedFoundData("Cannot open xml - \"" + QString::fromLocal8Bit(fileName)); + else stt->doEmitionRedFoundData("Cannot open xml - \"" + QString::fromLocal8Bit(fileName) + " Err:" + QString::number(GetLastError())); } rviStop = false;