mirror of
https://github.com/systemd/systemd.git
synced 2025-03-22 06:50:18 +03:00
strv: replace always-true condition with assertion
Follow-up for aca093018c5d2cd8a63129cab67941fe1b8fd850. Fixes CID#1547105.
This commit is contained in:
parent
07748c53df
commit
f2d2aa0934
@ -1053,20 +1053,20 @@ int strv_rebreak_lines(char **l, size_t width, char ***ret) {
|
||||
}
|
||||
}
|
||||
|
||||
if (start) { /* Process rest of the line */
|
||||
if (in_prefix) /* Never seen anything non-whitespace? Generate empty line! */
|
||||
r = strv_extend(&broken, "");
|
||||
else if (whitespace_begin && !whitespace_end) { /* Ends in whitespace? Chop it off! */
|
||||
_cleanup_free_ char *truncated = strndup(start, whitespace_begin - start);
|
||||
if (!truncated)
|
||||
return -ENOMEM;
|
||||
/* Process rest of the line */
|
||||
assert(start);
|
||||
if (in_prefix) /* Never seen anything non-whitespace? Generate empty line! */
|
||||
r = strv_extend(&broken, "");
|
||||
else if (whitespace_begin && !whitespace_end) { /* Ends in whitespace? Chop it off! */
|
||||
_cleanup_free_ char *truncated = strndup(start, whitespace_begin - start);
|
||||
if (!truncated)
|
||||
return -ENOMEM;
|
||||
|
||||
r = strv_consume(&broken, TAKE_PTR(truncated));
|
||||
} else /* Otherwise use line as is */
|
||||
r = strv_extend(&broken, start);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
r = strv_consume(&broken, TAKE_PTR(truncated));
|
||||
} else /* Otherwise use line as is */
|
||||
r = strv_extend(&broken, start);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
*ret = TAKE_PTR(broken);
|
||||
|
Loading…
x
Reference in New Issue
Block a user