Skip to content

Commit

Permalink
Fix leaked String and Variant in harnessPqScriptRun().
Browse files Browse the repository at this point in the history
  • Loading branch information
dwsteele committed Apr 28, 2022
1 parent ceb303f commit 8047e97
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions test/src/common/harnessPq.c
Expand Up @@ -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)
Expand Down Expand Up @@ -151,6 +161,8 @@ harnessPqScriptRun(const char *function, const VariantList *param, HarnessPq *pa
if (harnessPqScript[harnessPqScriptIdx].function == NULL)
harnessPqScriptDone = true;

strFree(paramStr);

return result;
}

Expand Down

0 comments on commit 8047e97

Please sign in to comment.