]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
efi: fix mangle_stub_cmdline() for empty strings
authorLennart Poettering <lennart@poettering.net>
Tue, 2 Jul 2024 14:01:28 +0000 (16:01 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 3 Jul 2024 14:15:04 +0000 (16:15 +0200)
src/boot/efi/util.c

index 3639afcb15d85bed7be233d283838ea265923c72..aafaf06e98bfff907209deeb56654fe0775371da 100644 (file)
@@ -42,19 +42,17 @@ static bool shall_be_whitespace(char16_t c) {
 }
 
 char16_t* mangle_stub_cmdline(char16_t *cmdline) {
-        char16_t *p, *q, *e;
-
         if (!cmdline)
                 return cmdline;
 
-        p = q = cmdline;
-
         /* Skip initial whitespace */
-        while (shall_be_whitespace(*p))
+        const char16_t *p = cmdline;
+        while (*p != 0 && shall_be_whitespace(*p))
                 p++;
 
         /* Turn inner control characters into proper spaces */
-        for (e = p; *p != 0; p++) {
+        char16_t *e = cmdline;
+        for (char16_t *q = cmdline; *p != 0; p++) {
                 if (shall_be_whitespace(*p)) {
                         *(q++) = ' ';
                         continue;