libCom: fix possible memory leaks in iocLogServer.c

found by static code analysis (cppcheck @ sonarqube)
This commit is contained in:
Ralph Lange
2023-05-26 09:20:04 +02:00
committed by Michael Davidsaver
parent 688195a273
commit 38c99df2e0

View File

@@ -113,8 +113,8 @@ int main(void)
pserver->pfdctx = (void *) fdmgr_init();
if (!pserver->pfdctx) {
free(pserver);
fprintf(stderr, "iocLogServer: %s\n", strerror(errno));
free(pserver);
return IOCLS_ERROR;
}
@@ -149,6 +149,7 @@ int main(void)
fprintf (stderr,
"iocLogServer: a server is already installed on port %u?\n",
(unsigned)ioc_log_port);
free(pserver);
return IOCLS_ERROR;
}
@@ -158,6 +159,7 @@ int main(void)
char sockErrBuf[64];
epicsSocketConvertErrnoToString ( sockErrBuf, sizeof ( sockErrBuf ) );
fprintf(stderr, "iocLogServer: listen err %s\n", sockErrBuf);
free(pserver);
return IOCLS_ERROR;
}
@@ -174,6 +176,7 @@ int main(void)
char sockErrBuf[64];
epicsSocketConvertErrnoToString ( sockErrBuf, sizeof ( sockErrBuf ) );
fprintf(stderr, "iocLogServer: ioctl FIONBIO err %s\n", sockErrBuf);
free(pserver);
return IOCLS_ERROR;
}
@@ -190,6 +193,7 @@ int main(void)
"File access problems to `%s' because `%s'\n",
ioc_log_file_name,
strerror(errno));
free(pserver);
return IOCLS_ERROR;
}
@@ -202,6 +206,7 @@ int main(void)
if (status < 0) {
fprintf(stderr,
"iocLogServer: failed to add read callback\n");
free(pserver);
return IOCLS_ERROR;
}