Edward-Wu/srt-live-server

SEGV if sls is executed directly

Opened this issue · 0 comments

Hello

if sls is executed directly, SEGV will received

Thread 1 "sls" received signal SIGSEGV, Segmentation fault.
0x0000000000409cb7 in sls_conf_release (c=0x0) at slscore/conf.cpp:360
360 if (c->child != NULL) {
(gdb) bt
#0 0x0000000000409cb7 in sls_conf_release (c=0x0) at slscore/conf.cpp:360
#1 0x0000000000409d7b in sls_conf_close () at slscore/conf.cpp:380
#2 0x0000000000404a26 in main (argc=1, argv=0x7fffffffe0a8) at srt-live-server.cpp:285
(gdb) q

Here is the patch to fix it, please check it.

diff --git a/slscore/conf.cpp b/slscore/conf.cpp
index 980d180..cf38e2e 100644
--- a/slscore/conf.cpp
+++ b/slscore/conf.cpp
@@ -357,6 +357,11 @@ int sls_conf_open(const char * conf_file)
 void sls_conf_release(sls_conf_base_t * c)
 {
     sls_conf_base_t * c_b;
+
+    if (c == NULL) {
+       return ;
+    }
+
     if (c->child != NULL) {
         c_b = c->child;
         sls_conf_release(c_b);

Best Regards