Fix some memory leaks and use-after-free (cppcheck)
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user