summaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorMark Whitley2001-04-23 17:04:41 +0000
committerMark Whitley2001-04-23 17:04:41 +0000
commit4b66dabc76a89a10e4ff07318ff88e3501a4bba5 (patch)
treeb0f9b03c749cdff64ea459ab7d7fc1fb16ea4f49 /libbb
parent8a24a65d2f90107f772b98f445bcdadd4d466207 (diff)
downloadbusybox-4b66dabc76a89a10e4ff07318ff88e3501a4bba5.zip
busybox-4b66dabc76a89a10e4ff07318ff88e3501a4bba5.tar.gz
Added a sanity check to fix weird bug exposed when sourcing in commands from a
file with lash. Based on report from Heinz Walter.
Diffstat (limited to 'libbb')
-rw-r--r--libbb/trim.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libbb/trim.c b/libbb/trim.c
index 78cf235..d3be62d 100644
--- a/libbb/trim.c
+++ b/libbb/trim.c
@@ -33,7 +33,11 @@
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]))