# HG changeset patch
# User websnarf <github@azillionmonkeys.com>
# Date 1445490244 25200
#      Wed Oct 21 22:04:04 2015 -0700
# Node ID 9060ef180820b1cc9fb91129c2bc09387ebf8825
# Parent  ca4a485f8d8477316f90e04acfccdb1d07c1a0b9
- Take care of case of a join on a bstrList with a length of 0.

diff --git a/bstest.c b/bstest.c
--- a/bstest.c
+++ b/bstest.c
@@ -1664,6 +1664,18 @@
 			}
 			if (ret) break;
 		}
+
+		l = bsplit (&emptyBstring, 'x');
+		bdestroy (l->entry[0]);
+		l->qty--;
+		b = bjoin (l, &longBstring);
+		bstrListDestroy (l);
+		if (b->slen) {
+			printf ("\t\tfailure(%d) ", __LINE__);
+			ret++;
+		}
+		bdestroy (b);
+
 	}
 
 	printf ("\t# failures: %d\n", ret);
diff --git a/bstrlib.c b/bstrlib.c
--- a/bstrlib.c
+++ b/bstrlib.c
@@ -2276,6 +2276,7 @@
 
 	if (bl == NULL || bl->qty < 0) return NULL;
 	if (sep != NULL && (sep->slen < 0 || sep->data == NULL)) return NULL;
+	if (bl->qty < 1) return bfromStatic ("");
 
 	for (i = 0, c = 1; i < bl->qty; i++) {
 		v = bl->entry[i]->slen;