split() and FOREACH_WORD really should die, and everything be moved to
extract_first_word() and friends, but let's at least make sure that for
the remaining code using it we can't deadlock by not progressing in the
word iteration.
Fixes: #15305
bool escaped = false;
int n;
- for (n=0; s[n]; n++) {
+ for (n = 0; s[n] != '\0'; n++) {
if (escaped)
escaped = false;
else if (s[n] == '\\')
break;
}
- /* if s ends in \, return index of previous char */
- return n - escaped;
+ return n;
}
/* Split a string into words. */
l = strv_split_full(" 'one' \" two\t three \"' four five", NULL, SPLIT_QUOTES | SPLIT_RELAX);
assert_se(l);
assert_se(strv_equal(l, (char**) input_table_quoted));
+
+ strv_free_erase(l);
+
+ l = strv_split_full("\\", NULL, SPLIT_QUOTES | SPLIT_RELAX);
+ assert_se(l);
+ assert_se(strv_equal(l, STRV_MAKE("\\")));
}
static void test_strv_split_empty(void) {