[Kde-bindings] KDE/kdebindings/smoke
Richard Dale
rdale at foton.es
Wed Dec 10 19:59:46 UTC 2008
On Wednesday 10 December 2008 19:39:22 Arno Rehn wrote:
> SVN commit 895455 by arnorehn:
>
> * Check for icur being 0 - otherwise strcmp could
> get a 0 const char* and crash. Fixes bug reported
> by Eric Butler. Thanks!
>
> CCMAIL: kde-bindings at kde.org
> CCMAIL: eric at extremeboredom.net
>
>
>
> M +3 -0 smoke.h
>
>
> --- trunk/KDE/kdebindings/smoke/smoke.h #895454:895455
> @@ -327,6 +327,7 @@
>
> while (imax >= imin) {
> icur = (imin + imax) / 2;
> + if (!icur) return 0;
> icmp = strcmp(types[icur].name, t);
> if (icmp == 0) {
> return icur;
> @@ -351,6 +352,7 @@
>
> while (imax >= imin) {
> icur = (imin + imax) / 2;
> + if (!icur) return NullModuleIndex;
> icmp = strcmp(classes[icur].className, c);
> if (icmp == 0) {
> if (classes[icur].external && !external) {
> @@ -428,6 +430,7 @@
>
> while (imax >= imin) {
> icur = (imin + imax) / 2;
> + if (!icur) return NullModuleIndex;
> icmp = leg(methodMaps[icur].classId, c);
> if (icmp == 0) {
> icmp = leg(methodMaps[icur].name, name);
I think this is the wrong fix. The problem is the dummy entries in the zeroth
element position - what are they there for? We need to either remove the and
initialize 'imin' to 0, or keep them and initialize 'imin' to 1. The need for
these 'if (!icur) return NullModuleIndex;' lines is just a symptom that
something is not quite right.
This should be a completely standard algorithm like the one here:
http://academics.tjhsst.edu/compsci/CS2C/U2/bisearch.html
-- Richard
More information about the Kde-bindings
mailing list