Skip to content

Commit

Permalink
Added a free statement to release memory allocated for postbuf if the…
Browse files Browse the repository at this point in the history
… memory allocation for inbuf fails. Resolves an error level issue generated by the Codacy static code analysis.

Codacy link: https://app.codacy.com/gh/epics-base/epics-base/file/42098735308/issues/source?bid=16430872&fileBranchId=16430872#l201
Launchpad bug: https://bugs.launchpad.net/epics-base/+bug/1862917

LP: #1862917
  • Loading branch information
Karl Vestin authored and mdavidsaver committed Feb 13, 2020
1 parent e6810a4 commit 538f532
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions modules/database/src/std/link/lnkCalc.c
Expand Up @@ -127,8 +127,8 @@ static jlif_result lnkCalc_integer(jlink *pjlink, long long num)
}

if (clink->pstate != ps_args) {
return jlif_stop;
errlogPrintf("lnkCalc: Unexpected integer %lld\n", num);
return jlif_stop;
}

if (clink->nArgs == CALCPERFORM_NARGS) {
Expand All @@ -147,8 +147,8 @@ static jlif_result lnkCalc_double(jlink *pjlink, double num)
calc_link *clink = CONTAINER(pjlink, struct calc_link, jlink);

if (clink->pstate != ps_args) {
return jlif_stop;
errlogPrintf("lnkCalc: Unexpected double %g\n", num);
return jlif_stop;
}

if (clink->nArgs == CALCPERFORM_NARGS) {
Expand Down Expand Up @@ -196,8 +196,9 @@ static jlif_result lnkCalc_string(jlink *pjlink, const char *val, size_t len)
}

inbuf = malloc(len+1);
if(!inbuf) {
if(!inbuf) {
errlogPrintf("lnkCalc: Out of memory\n");
free(postbuf);
return jlif_stop;
}
memcpy(inbuf, val, len);
Expand Down

0 comments on commit 538f532

Please sign in to comment.