changeset 135:3fb6ddd6b70d

str_trim: do nothing if *s is NULL.
author Sascha Wilde <wilde@intevation.de>
date Mon, 24 Mar 2014 15:34:28 +0100
parents 5f830969e4a1
children 5fa4791d6d0e
files common/strhelp.c
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/common/strhelp.c	Mon Mar 24 15:17:16 2014 +0100
+++ b/common/strhelp.c	Mon Mar 24 15:34:28 2014 +0100
@@ -129,9 +129,12 @@
 str_trim (char **s)
 {
   size_t i;
-  while (isspace(**s))
-    (*s)++;
-  i = strlen(*s);
-  while (isspace((*s)[--i]))
-    (*s)[i] = '\0';
+  if (*s != NULL)
+    {
+      while (isspace(**s))
+        (*s)++;
+      i = strlen(*s);
+      while (isspace((*s)[--i]))
+        (*s)[i] = '\0';
+    }
 }

http://wald.intevation.org/projects/trustbridge/