Fix some memory leaks and use-after-free (cppcheck)

This commit is contained in:
Douglas Clowes
2014-03-03 17:18:52 +11:00
parent be347e813c
commit 9e65849964
6 changed files with 34 additions and 18 deletions

View File

@@ -286,12 +286,15 @@
}
pNew = CreateEVDriver(argc,argv);
pSim = (pLAKESHORE340Driv)malloc(sizeof(LAKESHORE340Driv));
memset(pSim,0,sizeof(LAKESHORE340Driv));
if(!pNew || !pSim)
{
if (!pNew) {
return NULL;
}
pSim = (pLAKESHORE340Driv)malloc(sizeof(LAKESHORE340Driv));
if (!pSim) {
free(pNew);
return NULL;
}
memset(pSim,0,sizeof(LAKESHORE340Driv));
pNew->pPrivate = pSim;
pNew->KillPrivate = KillLAKESHORE340;