Fix memory leak in d2cs's main() when returning without calling xfree() on variable 'pidfile'
This commit is contained in:
parent
48291318e4
commit
699bdd42e3
1 changed files with 5 additions and 2 deletions
|
@ -252,23 +252,26 @@ extern int main(int argc, char ** argv)
|
|||
#endif
|
||||
{
|
||||
int pid;
|
||||
char * pidfile;
|
||||
|
||||
eventlog_set(stderr);
|
||||
if (!((pid = config_init(argc, argv)) == 0)) {
|
||||
// if (pid==1) pid=0;
|
||||
return pid;
|
||||
}
|
||||
pidfile = write_to_pidfile();
|
||||
const char* const pidfile = write_to_pidfile();
|
||||
eventlog(eventlog_level_info,__FUNCTION__,D2CS_VERSION);
|
||||
if (init()<0) {
|
||||
eventlog(eventlog_level_error,__FUNCTION__,"failed to init");
|
||||
if (pidfile)
|
||||
xfree((void*)pidfile);
|
||||
return -1;
|
||||
} else {
|
||||
eventlog(eventlog_level_info,__FUNCTION__,"server initialized");
|
||||
}
|
||||
if (d2cs_server_process()<0) {
|
||||
eventlog(eventlog_level_error,__FUNCTION__,"failed to run server");
|
||||
if (pidfile)
|
||||
xfree((void*)pidfile);
|
||||
return -1;
|
||||
}
|
||||
cleanup();
|
||||
|
|
Loading…
Reference in a new issue