From 41a0bc8fb60036ce10b7355f48ea6f5ebbac1bfb Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Mon, 19 May 2008 18:43:01 +0000 Subject: [PATCH] don't deref NULL. Found by Klockwork (www.klocwork.com) git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8468 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/switch_utils.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 == ' ') {