diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-06-18 11:12:39 +0200 |
---|---|---|
committer | Luca Boccassi <luca.boccassi@gmail.com> | 2024-06-18 22:09:04 +0200 |
commit | f2d2aa0934a07bd7f40cfe7304620a279cadb018 (patch) | |
tree | c84bc5fd438dacb5f69c71bdb5426ffc38183ca2 /src/basic/strv.c | |
parent | Merge pull request #33386 from yuwata/journal-timestamp (diff) | |
download | systemd-f2d2aa0934a07bd7f40cfe7304620a279cadb018.tar.xz systemd-f2d2aa0934a07bd7f40cfe7304620a279cadb018.zip |
strv: replace always-true condition with assertion
Follow-up for aca093018c5d2cd8a63129cab67941fe1b8fd850.
Fixes CID#1547105.
Diffstat (limited to '')
-rw-r--r-- | src/basic/strv.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/basic/strv.c b/src/basic/strv.c index 1ca5118eff..6c71f990c8 100644 --- a/src/basic/strv.c +++ b/src/basic/strv.c @@ -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; - - r = strv_consume(&broken, TAKE_PTR(truncated)); - } else /* Otherwise use line as is */ - r = strv_extend(&broken, start); - if (r < 0) - return r; - } + /* 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; } *ret = TAKE_PTR(broken); |