summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2022-04-30 11:38:44 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2022-04-30 11:38:44 -0700
commit337a55d303d76aa4f3f6d1e4d7885544436ee2be (patch)
tree4afdd4e5b8323c65c031f14ce3f2c2598311ad11
parent6ff9e623b48a8998324a75ebaadb6adc97b189ae (diff)
LoadSCCData: avoid leaking memory if we give up early
Resolves issues reported by Oracle Parfait static analyser: Error: Memory leak Memory leak [memory-leak] (CWE 401): Memory leak of pointer pCurrent allocated with calloc(1, 112) at line 1615 of app/xcmsdb/loadData.c in function 'LoadSCCData'. pCurrent allocated at line 1600 with calloc(1, 112) Error: Memory leak Memory leak [memory-leak] (CWE 401): Memory leak of pointer pCurrent allocated with calloc(1, 112) at line 1634 of app/xcmsdb/loadData.c in function 'LoadSCCData'. pCurrent allocated at line 1600 with calloc(1, 112) pCurrent leaks when VisualFlag == 0 at line 1618 and VisualFlag == 0 at line 1626. Error: Memory leak Memory leak [memory-leak] (CWE 401): Memory leak of pointer pCurrent allocated with calloc(1, 112) at line 1656 of app/xcmsdb/loadData.c in function 'LoadSCCData'. pCurrent allocated at line 1600 with calloc(1, 112) pCurrent leaks when VisualFlag == 0 at line 1618 and VisualFlag == 0 at line 1626 and pCurrent->nTables != 0 at line 1628 and pCurrent->nTables != 1 at line 1628 and token3 == NULL at line 1642 and pCurrent->nTables is 3 at line 1648 and pCurrent->pRedTbl == NULL at line 1651. Memory leak [memory-leak] (CWE 401): Memory leak of pointer pCurrent allocated with calloc(1, 112) at line 1664 of app/xcmsdb/loadData.c in function 'LoadSCCData'. pCurrent allocated at line 1600 with calloc(1, 112) pCurrent leaks when VisualFlag == 0 at line 1618 and VisualFlag == 0 at line 1626 and pCurrent->nTables != 0 at line 1628 and pCurrent->nTables != 1 at line 1628 and token3 == NULL at line 1642 and pCurrent->nTables is 3 at line 1648 and pCurrent->pGreenTbl == NULL at line 1659. Memory leak [memory-leak] (CWE 401): Memory leak of pointer pCurrent allocated with calloc(1, 112) at line 1672 of app/xcmsdb/loadData.c in function 'LoadSCCData'. pCurrent allocated at line 1600 with calloc(1, 112) pCurrent leaks when VisualFlag == 0 at line 1618 and VisualFlag == 0 at line 1626 and pCurrent->nTables != 0 at line 1628 and pCurrent->nTables != 1 at line 1628 and token3 == NULL at line 1642 and pCurrent->nTables is 3 at line 1648 and pCurrent->pBlueTbl == NULL at line 1667. Memory leak [memory-leak] (CWE 401): Memory leak of pointer pCurrent allocated with calloc(1, 112) at line 1685 of app/xcmsdb/loadData.c in function 'LoadSCCData'. pCurrent allocated at line 1600 with calloc(1, 112) pCurrent leaks when VisualFlag == 0 at line 1618 and VisualFlag == 0 at line 1626 and pCurrent->nTables != 0 at line 1628 and pCurrent->nTables == 1 at line 1628 and token3 == NULL at line 1642 and pCurrent->nTables is 1 at line 1648 and pCurrent->pRedTbl == NULL at line 1680. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--loadData.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/loadData.c b/loadData.c
index a676855..119a4ba 100644
--- a/loadData.c
+++ b/loadData.c
@@ -1612,6 +1612,7 @@ LoadSCCData(Display *pDpy, int screenNumber, const char *filename,
"Line %d: invalid table type specified -- %s\n",
linenum, buf);
closeS(stream, CorrectionHead);
+ free(pCurrent);
return (0);
}
@@ -1620,6 +1621,7 @@ LoadSCCData(Display *pDpy, int screenNumber, const char *filename,
"Line %d: invalid number of tables specified -- %s\n",
linenum, buf);
closeS(stream, CorrectionHead);
+ free(pCurrent);
return (0);
}
@@ -1631,6 +1633,7 @@ LoadSCCData(Display *pDpy, int screenNumber, const char *filename,
"Line %d: invalid number of tables (must be 0, 1, or 3)\n",
linenum);
closeS(stream, CorrectionHead);
+ free(pCurrent);
return (0);
}
}
@@ -1653,6 +1656,7 @@ LoadSCCData(Display *pDpy, int screenNumber, const char *filename,
"Line %d: Could not allocate Red Intensity Table\n",
linenum);
closeS(stream, CorrectionHead);
+ free(pCurrent);
return (0);
}
pCurrent->pGreenTbl = calloc(1, sizeof(IntensityTbl));
@@ -1661,6 +1665,8 @@ LoadSCCData(Display *pDpy, int screenNumber, const char *filename,
"Line %d: Could not allocate Green Intensity Table\n",
linenum);
closeS(stream, CorrectionHead);
+ free(pCurrent->pRedTbl);
+ free(pCurrent);
return (0);
}
pCurrent->pBlueTbl = calloc(1, sizeof(IntensityTbl));
@@ -1669,6 +1675,9 @@ LoadSCCData(Display *pDpy, int screenNumber, const char *filename,
"Line %d: Could not allocate Blue Intensity Table",
linenum);
closeS(stream, CorrectionHead);
+ free(pCurrent->pRedTbl);
+ free(pCurrent->pGreenTbl);
+ free(pCurrent);
return (0);
}
if (!ProcessIProfile(stream, pCurrent)) {
@@ -1682,6 +1691,7 @@ LoadSCCData(Display *pDpy, int screenNumber, const char *filename,
"Line %d: Could not allocate Red Intensity Table",
linenum);
closeS(stream, CorrectionHead);
+ free(pCurrent);
return (0);
}
pCurrent->pGreenTbl = pCurrent->pRedTbl;