Skip to content

Commit

Permalink
string: on strstrip(), first remove leading spaces before running ove…
Browse files Browse the repository at this point in the history
…r str

... so that strlen() iterates over a smaller string comprising of the
remaining characters only.

Signed-off-by: André Goddard Rosa <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
andre-rosa authored and torvalds committed Dec 15, 2009
1 parent f653398 commit 84c95c9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,8 @@ char *strstrip(char *s)
size_t size;
char *end;

s = skip_spaces(s);
size = strlen(s);

if (!size)
return s;

Expand All @@ -374,7 +374,7 @@ char *strstrip(char *s)
end--;
*(end + 1) = '\0';

return skip_spaces(s);
return s;
}
EXPORT_SYMBOL(strstrip);

Expand Down

0 comments on commit 84c95c9

Please sign in to comment.