diff --git a/src/switch_utils.c b/src/switch_utils.c index d64dae7829..b59bbfffcb 100644 --- a/src/switch_utils.c +++ b/src/switch_utils.c @@ -568,12 +568,16 @@ SWITCH_DECLARE(char *) switch_strip_spaces(const char *str) const char *sp = str; char *p, *s = NULL; - while(sp && *sp && *sp == ' ') { + if (!sp) return NULL; + + while(*sp == ' ') { sp++; } s = strdup(sp); + if (!s) return NULL; + p = s + (strlen(s) - 1); while(*p == ' ') {