Added a sanity check to fix weird bug exposed when sourcing in commands from a
file with lash. Based on report from Heinz Walter.
This commit is contained in:
@@ -35,6 +35,10 @@ void trim(char *s)
|
|||||||
{
|
{
|
||||||
int len = strlen(s);
|
int len = strlen(s);
|
||||||
|
|
||||||
|
/* sanity check */
|
||||||
|
if (len == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
/* trim trailing whitespace */
|
/* trim trailing whitespace */
|
||||||
while ( len > 0 && isspace(s[len-1]))
|
while ( len > 0 && isspace(s[len-1]))
|
||||||
s[--len]='\0';
|
s[--len]='\0';
|
||||||
|
Reference in New Issue
Block a user