diff options
Diffstat (limited to 'libbb/compare_string_array.c')
-rw-r--r-- | libbb/compare_string_array.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libbb/compare_string_array.c b/libbb/compare_string_array.c index 856739c41..ede5a97e3 100644 --- a/libbb/compare_string_array.c +++ b/libbb/compare_string_array.c | |||
@@ -158,8 +158,11 @@ int FAST_FUNC index_in_substrings(const char *strings, const char *key) | |||
158 | const char* FAST_FUNC nth_string(const char *strings, int n) | 158 | const char* FAST_FUNC nth_string(const char *strings, int n) |
159 | { | 159 | { |
160 | while (n) { | 160 | while (n) { |
161 | n--; | 161 | if (*strings++ == '\0') { |
162 | strings += strlen(strings) + 1; | 162 | if (*strings == '\0') /* reached end of strings */ |
163 | break; | ||
164 | n--; | ||
165 | } | ||
163 | } | 166 | } |
164 | return strings; | 167 | return strings; |
165 | } | 168 | } |