]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic/strbuf: do not call bsearch with a null argument
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 18 Feb 2016 22:33:10 +0000 (17:33 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 19 Feb 2016 00:39:09 +0000 (19:39 -0500)
Das ist verboten!

src/basic/strbuf.c:162:23: runtime error: null pointer passed as argument 2,
                           which is declared to never be null

src/basic/strbuf.c

index 77220c025147337e126fbe12d3a1197fb79785ac..dac288160392adf755f765cddb81251c427fe792 100644 (file)
@@ -156,6 +156,10 @@ ssize_t strbuf_add_string(struct strbuf *str, const char *s, size_t len) {
                         return off;
                 }
 
+                /* bsearch is not allowed on a NULL sequence */
+                if (node->children_count == 0)
+                        break;
+
                 /* lookup child node */
                 c = s[len - 1 - depth];
                 search.c = c;