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

@@ -909,8 +909,12 @@ pCodri MakeTcpDoChoDriver(char *tclArray, SConnection *pCon){
allocate memory
*/
pNew = (pCodri)malloc(sizeof(Codri));
if(!pNew){
return NULL;
}
self = (pTcpDoCho)malloc(sizeof(TcpDoCho));
if(!pNew || !self){
if(!self){
free(pNew);
return NULL;
}
memset(pNew,0,sizeof(Codri));
@@ -952,6 +956,7 @@ pCodri MakeTcpDoChoDriver(char *tclArray, SConnection *pCon){
SCWrite(pCon,"ERROR: number of choppers not in range 1 - 8",eError);
free(pNew);
free(self);
return NULL;
}
self->numChoppers = port;