]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
loader.c: Fix possible SEGV when a module fails to register
authorGeorge Joseph <gjoseph@digium.com>
Mon, 29 Jul 2019 13:31:56 +0000 (07:31 -0600)
committerGeorge Joseph <gjoseph@digium.com>
Mon, 29 Jul 2019 13:39:28 +0000 (07:39 -0600)
When a module fails to register itself (usually a coding error
in the module), dlerror() can return NULL.  We weren't checking
for that in load_dlopen() before trying to strdup the error message
so a SEGV was thrown.  dlerror() is now surrounded with an S_OR
so we don't SEGV.

Change-Id: Ie0fb9316f08a321434f3f85aecf3c7d2ede8b956

main/loader.c

index b46f745af8fdcec7ca6a211b9324e1da441ec944..033693e8b09bc031075ed9eecf638f388e13a176 100644 (file)
@@ -1087,7 +1087,7 @@ static struct ast_module *load_dlopen(const char *resource_in, const char *so_ex
        if (resource_being_loaded) {
                struct ast_str *list;
                int c = 0;
-               const char *dlerror_msg = ast_strdupa(dlerror());
+               const char *dlerror_msg = ast_strdupa(S_OR(dlerror(), ""));
 
                resource_being_loaded = NULL;
                if (mod->lib) {