]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod: call fnmatch() only as needed
authorEmil Velikov <emil.l.velikov@gmail.com>
Tue, 8 Oct 2024 17:04:34 +0000 (18:04 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 15 Oct 2024 14:30:59 +0000 (09:30 -0500)
Currently we'll call the function even when the patterns is an empty
string.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/174
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
libkmod/libkmod-index.c

index 4280be8d95c111ab2afa4112de54d3010f4b889e..6fe019aeb5c6df27b94aa26de24fdaebd36b0b7b 100644 (file)
@@ -511,7 +511,7 @@ static void index_searchwild__all(struct index_node_f *node, int j, struct strbu
                }
        }
 
-       if (node->values) {
+       if (pushed && node->values) {
                const char *s = strbuf_str(buf);
 
                if (s != NULL && fnmatch(s, subkey, 0) == 0)
@@ -997,7 +997,7 @@ static void index_mm_searchwild_all(struct index_mm_node *node, int j, struct st
                }
        }
 
-       if (node->values.len > 0) {
+       if (pushed && node->values.len > 0) {
                const char *s = strbuf_str(buf);
 
                if (s != NULL && fnmatch(s, subkey, 0) == 0)