CodeQL MemoryMayNotBeFreed.ql ResRex.c ResCheckSimNodes()

created use of 'alloc' local variable to track when an allocation occurred
so exit path logic is more straight forward for compiler/analyser to see
potential optimisations.
This commit is contained in:
Darryl L. Miles 2025-02-13 08:37:23 +00:00 committed by Tim Edwards
parent c33b6be2bb
commit 37fa75dd77
1 changed files with 3 additions and 2 deletions

View File

@ -997,17 +997,18 @@ ResCheckSimNodes(celldef, resisdata)
if (ResOptionsFlags & ResOpt_DoExtFile)
{
char *alloc = NULL;
if (ExtLocalPath != NULL)
if (strcmp(ExtLocalPath, "."))
{
char *namebuf;
namebuf = mallocMagic(strlen(ExtLocalPath) + strlen(celldef->cd_name)
namebuf = alloc = mallocMagic(strlen(ExtLocalPath) + strlen(celldef->cd_name)
+ 2);
sprintf(namebuf, "%s/%s", ExtLocalPath, celldef->cd_name);
outfile = namebuf;
}
ResExtFile = PaOpen(outfile, "w", ".res.ext", ".", (char *)NULL, (char **)NULL);
if (outfile != celldef->cd_name) freeMagic(outfile);
if (alloc) freeMagic(alloc);
outfile = celldef->cd_name;
}
else