diff --git a/bstest.c b/bstest.c
index d208b2046ab561688e2b612dab0d76c9c6b44460_YnN0ZXN0LmM=..a64148ad7a67c78c3544bc62f3dcd71def9b5569_YnN0ZXN0LmM= 100644
--- a/bstest.c
+++ b/bstest.c
@@ -1680,6 +1680,12 @@
 struct tagbstring is = bsStatic ("is");
 struct tagbstring ng = bsStatic ("ng");
 struct tagbstring commas = bsStatic (",,,,");
+struct tagbstring delim = bsStatic ("aa");
+struct tagbstring beginWithDelim = bsStatic ("aaabcdaa1");
+struct tagbstring endWithDelim = bsStatic ("1aaabcdaa");
+struct tagbstring conseqDelim = bsStatic ("1aaaa1");
+struct tagbstring oneCharLeft = bsStatic ("aaaaaaa");
+struct tagbstring allDelim = bsStatic ("aaaaaa");
 int ret = 0;
 
 	printf ("TEST: struct bstrList * bsplit (const_bstring str, unsigned char splitChar);\n");
@@ -1707,6 +1713,16 @@
 	ret += test21_1 (&longBstring, &is, 3);
 	ret += test21_1 (&longBstring, &ng, 5);
 
+	/* corner cases */
+	ret += test21_1 (&shortBstring, &emptyBstring, shortBstring.slen);
+	ret += test21_1 (&emptyBstring, &delim, 1);
+	ret += test21_1 (&delim, &delim, 2);
+	ret += test21_1 (&beginWithDelim, &delim, 3);
+	ret += test21_1 (&endWithDelim, &delim, 3);
+	ret += test21_1 (&conseqDelim, &delim, 3);
+	ret += test21_1 (&oneCharLeft, &delim, 4);
+	ret += test21_1 (&allDelim, &delim, 4);
+
 	if (0 == ret) {
 		struct bstrList * l;
 		unsigned char c;
diff --git a/bstrlib.c b/bstrlib.c
index d208b2046ab561688e2b612dab0d76c9c6b44460_YnN0cmxpYi5j..a64148ad7a67c78c3544bc62f3dcd71def9b5569_YnN0cmxpYi5j 100644
--- a/bstrlib.c
+++ b/bstrlib.c
@@ -2768,10 +2768,11 @@
 	if (splitStr->slen == 1)
 		return bsplitcb (str, splitStr->data[0], pos, cb, parm);
 
-	for (i=p=pos; i <= str->slen - splitStr->slen; i++) {
+	i = p = pos;
+	while (i <= str->slen - splitStr->slen) {
 		if (0 == bstr__memcmp (splitStr->data, str->data + i,
 		                       splitStr->slen)) {
 			if ((ret = cb (parm, p, i - p)) < 0) return ret;
 			i += splitStr->slen;
 			p = i;
 		}
@@ -2772,9 +2773,12 @@
 		if (0 == bstr__memcmp (splitStr->data, str->data + i,
 		                       splitStr->slen)) {
 			if ((ret = cb (parm, p, i - p)) < 0) return ret;
 			i += splitStr->slen;
 			p = i;
 		}
+		else {
+			i++;
+		}
 	}
 	if ((ret = cb (parm, p, str->slen - p)) < 0) return ret;
 	return BSTR_OK;