mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-14 01:49:05 +00:00
FS-8537: Passing nil to various lua functions causes segfault
Various functions exposed via lua do not check their parameters for null causing freeswitch to segfault. This change adds checking for null parameters and returns an error instead of segfaulting.
This commit is contained in:
@@ -393,11 +393,13 @@ SWITCH_DECLARE(char *) switch_core_get_variable_dup(const char *varname)
|
||||
{
|
||||
char *val = NULL, *v;
|
||||
|
||||
switch_thread_rwlock_rdlock(runtime.global_var_rwlock);
|
||||
if ((v = (char *) switch_event_get_header(runtime.global_vars, varname))) {
|
||||
val = strdup(v);
|
||||
if (varname) {
|
||||
switch_thread_rwlock_rdlock(runtime.global_var_rwlock);
|
||||
if ((v = (char *) switch_event_get_header(runtime.global_vars, varname))) {
|
||||
val = strdup(v);
|
||||
}
|
||||
switch_thread_rwlock_unlock(runtime.global_var_rwlock);
|
||||
}
|
||||
switch_thread_rwlock_unlock(runtime.global_var_rwlock);
|
||||
|
||||
return val;
|
||||
}
|
||||
@@ -406,11 +408,13 @@ SWITCH_DECLARE(char *) switch_core_get_variable_pdup(const char *varname, switch
|
||||
{
|
||||
char *val = NULL, *v;
|
||||
|
||||
switch_thread_rwlock_rdlock(runtime.global_var_rwlock);
|
||||
if ((v = (char *) switch_event_get_header(runtime.global_vars, varname))) {
|
||||
val = switch_core_strdup(pool, v);
|
||||
if (varname) {
|
||||
switch_thread_rwlock_rdlock(runtime.global_var_rwlock);
|
||||
if ((v = (char *) switch_event_get_header(runtime.global_vars, varname))) {
|
||||
val = switch_core_strdup(pool, v);
|
||||
}
|
||||
switch_thread_rwlock_unlock(runtime.global_var_rwlock);
|
||||
}
|
||||
switch_thread_rwlock_unlock(runtime.global_var_rwlock);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
Reference in New Issue
Block a user