Added a sanity check to fix weird bug exposed when sourcing in commands from a
authorMark Whitley <markw@lineo.com>
Mon, 23 Apr 2001 17:04:41 +0000 (17:04 -0000)
committerMark Whitley <markw@lineo.com>
Mon, 23 Apr 2001 17:04:41 +0000 (17:04 -0000)
file with lash. Based on report from Heinz Walter.

libbb/trim.c

index 78cf235dd006cae01c326006d69e2d79e24f3e18..d3be62d9381dbf3a070b9f17a3f86edbc5492ea1 100644 (file)
 
 void trim(char *s)
 {
-       int len=strlen(s);
+       int len = strlen(s);
+
+       /* sanity check */
+       if (len == 0)
+               return;
 
        /* trim trailing whitespace */
        while ( len > 0 && isspace(s[len-1]))