Skip to content

Commit 84c95c9

Browse files
andre-rosatorvalds
authored andcommitted
string: on strstrip(), first remove leading spaces before running over 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]>
1 parent f653398 commit 84c95c9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/string.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,8 @@ char *strstrip(char *s)
364364
size_t size;
365365
char *end;
366366

367+
s = skip_spaces(s);
367368
size = strlen(s);
368-
369369
if (!size)
370370
return s;
371371

@@ -374,7 +374,7 @@ char *strstrip(char *s)
374374
end--;
375375
*(end + 1) = '\0';
376376

377-
return skip_spaces(s);
377+
return s;
378378
}
379379
EXPORT_SYMBOL(strstrip);
380380

0 commit comments

Comments
 (0)