diff options
author | Joerg Bornemann <joerg.bornemann@nokia.com> | 2010-05-05 15:42:54 (GMT) |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@nokia.com> | 2010-05-05 15:42:54 (GMT) |
commit | 2cc7a785eff228f414faa09ff882c2f0a2092cfd (patch) | |
tree | 838f816b717349175be35fda17c698a80402bc0e /src/corelib/kernel | |
parent | 93c2e88ee31b989e44a17da99a9d256a9bf1b28a (diff) | |
download | Qt-2cc7a785eff228f414faa09ff882c2f0a2092cfd.zip Qt-2cc7a785eff228f414faa09ff882c2f0a2092cfd.tar.gz Qt-2cc7a785eff228f414faa09ff882c2f0a2092cfd.tar.bz2 |
fix qt_wince_bsearch for low nonexistent key values
Task-number: QTBUG-10043
Reviewed-by: thartman
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r-- | src/corelib/kernel/qfunctions_wince.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/corelib/kernel/qfunctions_wince.cpp b/src/corelib/kernel/qfunctions_wince.cpp index 8ad6126..e58feb3 100644 --- a/src/corelib/kernel/qfunctions_wince.cpp +++ b/src/corelib/kernel/qfunctions_wince.cpp @@ -352,16 +352,18 @@ void *qt_wince_bsearch(const void *key, size_t low = 0; size_t high = num - 1; while (low <= high) { - unsigned int mid = ((unsigned) (low + high)) >> 1; + size_t mid = (low + high) >> 1; int c = compare(key, (char*)base + mid * size); - if (c < 0) + if (c < 0) { + if (!mid) + break; high = mid - 1; - else if (c > 0) + } else if (c > 0) low = mid + 1; else return (char*) base + mid * size; } - return (NULL); + return 0; } void *lfind(const void* key, const void* base, size_t* elements, size_t size, |