]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
extract-word: Check for early bail out before inspecting separators
authorFilipe Brandenburger <filbranden@google.com>
Fri, 6 Nov 2015 05:31:29 +0000 (21:31 -0800)
committerFilipe Brandenburger <filbranden@google.com>
Fri, 6 Nov 2015 05:31:29 +0000 (21:31 -0800)
It's a pretty small optimization but doesn't hurt...

Tested with test-extract-word.

src/basic/extract-word.c

index 1b3123bb7d83e6c7437ccf7b385ea76df358d698..b08851b89bc3381f646e7d20ae2eed6f1f226f79 100644 (file)
@@ -39,13 +39,13 @@ int extract_first_word(const char **p, char **ret, const char *separators, Extra
         assert(p);
         assert(ret);
 
-        if (!separators)
-                separators = WHITESPACE;
-
         /* Bail early if called after last value or with no input */
         if (!*p)
                 goto finish_force_terminate;
 
+        if (!separators)
+                separators = WHITESPACE;
+
         /* Parses the first word of a string, and returns it in
          * *ret. Removes all quotes in the process. When parsing fails
          * (because of an uneven number of quotes or similar), leaves