Fix potential memory leak on error
In osdThread.c for POSIX if pthread_create_key fails In iocLogServer.c if fdmgr_init returns NULL In dbBkpt.c if semaphore creation fails while adding a bp to a lockset In devSiSoftCallback.c if linked record is not found
This commit is contained in:
@@ -331,6 +331,7 @@ long dbb(const char *record_name)
|
||||
if (pnode->ex_sem == NULL) {
|
||||
printf(" BKPT> Out of memory\n");
|
||||
dbScanUnlock(precord);
|
||||
free(pnode);
|
||||
epicsMutexUnlock(bkpt_stack_sem);
|
||||
return(1);
|
||||
}
|
||||
|
||||
@@ -108,6 +108,7 @@ static long add_record(dbCommon *pcommon)
|
||||
|
||||
recGblRecordError(status, (void *)prec,
|
||||
"devSiSoftCallback (add_record) linked record not found");
|
||||
free(pdevPvt);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
@@ -113,6 +113,7 @@ int main(void)
|
||||
|
||||
pserver->pfdctx = (void *) fdmgr_init();
|
||||
if (!pserver->pfdctx) {
|
||||
free(pserver);
|
||||
fprintf(stderr, "iocLogServer: %s\n", strerror(errno));
|
||||
return IOCLS_ERROR;
|
||||
}
|
||||
|
||||
@@ -956,8 +956,10 @@ LIBCOM_API epicsThreadPrivateId epicsStdCall epicsThreadPrivateCreate(void)
|
||||
return NULL;
|
||||
status = pthread_key_create(key,0);
|
||||
checkStatus(status,"pthread_key_create epicsThreadPrivateCreate");
|
||||
if(status)
|
||||
if(status) {
|
||||
free(key);
|
||||
return NULL;
|
||||
}
|
||||
return((epicsThreadPrivateId)key);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user