1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-12 10:04:14 +02:00

Fix leaked String and Variant in harnessPqScriptRun().

This commit is contained in:
David Steele 2022-04-28 12:17:33 -04:00
parent ceb303f9e2
commit 8047e97e31

View File

@ -73,14 +73,24 @@ harnessPqScriptStrictSet(bool strict)
Run pq script
***********************************************************************************************************************************/
static HarnessPq *
harnessPqScriptRun(const char *function, const VariantList *param, HarnessPq *parent)
harnessPqScriptRun(const char *const function, const VariantList *const param, const HarnessPq *const parent)
{
// If an error has already been thrown then throw the same error again
if (harnessPqScriptFail)
THROW(AssertError, harnessPqScriptError);
// Convert params to json for comparison and reporting
String *paramStr = param ? jsonFromVar(varNewVarLst(param)) : strNew();
String *paramStr = NULL;
if (param)
{
Variant *const varList = varNewVarLst(param);
paramStr = jsonFromVar(varList);
varFree(varList);
}
else
paramStr = strNew();
// Ensure script has not ended
if (harnessPqScriptDone)
@ -151,6 +161,8 @@ harnessPqScriptRun(const char *function, const VariantList *param, HarnessPq *pa
if (harnessPqScript[harnessPqScriptIdx].function == NULL)
harnessPqScriptDone = true;
strFree(paramStr);
return result;
}