]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/basic/strbuf.c
Merge pull request #2709 from vcaputo/normalize_inc_dec_usage
[thirdparty/systemd.git] / src / basic / strbuf.c
index 77220c025147337e126fbe12d3a1197fb79785ac..797f00cf7165f52485d659f2f80c23eaa49c6e4c 100644 (file)
@@ -121,7 +121,7 @@ static void bubbleinsert(struct strbuf_node *node,
                 sizeof(struct strbuf_child_entry) * (node->children_count - left));
         node->children[left] = new;
 
-        node->children_count ++;
+        node->children_count++;
 }
 
 /* add string, return the index/offset into the buffer */
@@ -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;