summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2010-09-20 20:02:16 -0400
committerDana Jansens <danakj@orodu.net>2011-01-24 14:19:22 -0500
commit7eeae03f0668cbdfe461d126e076dd97a98b6b05 (patch)
treeda75b419b3a80cc15e24709b81b2143952f4f75e
parentd3660704f1195fb724f5c0c027bdd084824c511f (diff)
oops, crash if searching for something smaller than * in the array
-rw-r--r--obt/bsearch.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/obt/bsearch.h b/obt/bsearch.h
index 65e42680..9613c51b 100644
--- a/obt/bsearch.h
+++ b/obt/bsearch.h
@@ -40,8 +40,9 @@ G_BEGIN_DECLS
if ((val) == (ar)[out_BSEARCH]) { \
break; \
} \
- else if ((val) < (ar)[out_BSEARCH]) \
+ else if ((val) < (ar)[out_BSEARCH] && out_BSEARCH > 0) { \
r_BSEARCH = out_BSEARCH-1; /* search to the left side */ \
+ } \
else \
l_BSEARCH = out_BSEARCH+1; /* search to the left side */ \
} \