diff --git a/src/bin/pg_rewind/fetch.cpp b/src/bin/pg_rewind/fetch.cpp index 233a70b3939365f261c2d25705c25842111953c5..14b157395691fc610b121219140e733303479b94 100755 --- a/src/bin/pg_rewind/fetch.cpp +++ b/src/bin/pg_rewind/fetch.cpp @@ -396,10 +396,13 @@ static BuildErrorCode receiveFileChunks(const char* sql, FILE* file) switch (PQresultStatus(res)) { case PGRES_SINGLE_TUPLE: + PQclear(res); + res = nullptr; break; case PGRES_TUPLES_OK: PQclear(res); + res = nullptr; continue; /* final zero-row result */ default: @@ -500,6 +503,8 @@ static BuildErrorCode receiveFileChunks(const char* sql, FILE* file) FetchCompressedFile(chunk, (uint32)chunkoff, (int32)chunkspace, (uint16)chunkSize, (uint8)algorithm); } PG_CHECKBUILD_AND_FREE_PGRESULT_RETURN(res); + PQclear(res); + res = nullptr; } g_progressFlag = true; diff --git a/src/bin/pg_rewind/parsexlog.cpp b/src/bin/pg_rewind/parsexlog.cpp index 97dc64dd8ae39b973a535cd41bc498138c969b31..cd44c20abeae5fabdf8ec8044cc98e2802156b9c 100644 --- a/src/bin/pg_rewind/parsexlog.cpp +++ b/src/bin/pg_rewind/parsexlog.cpp @@ -732,9 +732,12 @@ bool CheckIfEanbedSaveSlots() securec_check_c(ret, "", ""); if ((strcmp(optvalue, "1") == 0) || (strcmp(optvalue, "true") == 0) || (strcmp(optvalue, "on") == 0)) { pg_log(PG_PROGRESS, _("Enable saving confirmed_lsn in target %s\n"), config_file); + freefile(optlines); + optlines = nullptr; return true; } } - + freefile(optlines); + optlines = nullptr; return false; }