Skip to content

Commit 9dc6142

Browse files
mauriciovasquezbernalfrisso
authored andcommitted
polycubed: fix segfault on init (#114)
* polycubed: fix segfault on init When SIGINT was received at initialization time there was segfault because the handler tried to delete the core and rest server that were not allocated yet. This commit adds a check to be sure that core and rest server are allocated when the shutdown handler is invoked. Fixes: 0df5d81 ("Initial commit") Signed-off-by: Mauricio Vasquez B <mauriciovasquezbernal@gmail.com> * Update polycubed.cpp
1 parent 1525d37 commit 9dc6142

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/polycubed/src/polycubed.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,13 @@ void shutdown() {
6060
return;
6161
// Service controllers depend on Rest Server. It is required to remove them
6262
// before clearing the rest server in order to avoid segmentation faults.
63-
core->clear_servicectrl_list();
64-
restserver->shutdown();
65-
logger->debug("rest was shutdown");
66-
delete core;
63+
if (core && restserver) {
64+
core->clear_servicectrl_list();
65+
restserver->shutdown();
66+
logger->debug("rest server shutdown");
67+
delete core;
68+
delete restserver;
69+
}
6770
logger->info("polycubed is shutting down. Bye!");
6871
done = true;
6972
}

0 commit comments

Comments
 (0)