Blame 0009-basic-strbuf-do-not-call-bsearch-with-a-null-argumen.patch

2b6823
From 328e8daf82c4e82ebcd06ae87bb825d5060cb94b Mon Sep 17 00:00:00 2001
2b6823
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
2b6823
Date: Thu, 18 Feb 2016 17:33:10 -0500
2b6823
Subject: [PATCH] basic/strbuf: do not call bsearch with a null argument
2b6823
2b6823
Das ist verboten!
2b6823
2b6823
src/basic/strbuf.c:162:23: runtime error: null pointer passed as argument 2,
2b6823
                           which is declared to never be null
2b6823
2b6823
(cherry picked from commit 82501b3fc40dae2660a86ab07462f33fe26347ad)
2b6823
---
2b6823
 src/basic/strbuf.c | 4 ++++
2b6823
 1 file changed, 4 insertions(+)
2b6823
2b6823
diff --git a/src/basic/strbuf.c b/src/basic/strbuf.c
2b6823
index 77220c0251..dac2881603 100644
2b6823
--- a/src/basic/strbuf.c
2b6823
+++ b/src/basic/strbuf.c
2b6823
@@ -156,6 +156,10 @@ ssize_t strbuf_add_string(struct strbuf *str, const char *s, size_t len) {
2b6823
                         return off;
2b6823
                 }
2b6823
 
2b6823
+                /* bsearch is not allowed on a NULL sequence */
2b6823
+                if (node->children_count == 0)
2b6823
+                        break;
2b6823
+
2b6823
                 /* lookup child node */
2b6823
                 c = s[len - 1 - depth];
2b6823
                 search.c = c;