[Kde-bindings] KDE/kdebindings/smoke
Arno Rehn
arno at arnorehn.de
Thu Dec 11 15:15:28 UTC 2008
On Wednesday 10 December 2008 20:59:46 Richard Dale wrote:
> 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
Yes, you're right. Then we should initialize imin to 1. I'd keep the dummy
entries, because NullModuleIndex also points to these. We could make
NullModuleIndex be { 0, -1 }, though that would require some code changes and
make the syntax look not so nice (i.e. always checking for mi.index < 0
instead of simply !mi.index).
--
Arno Rehn
arno at arnorehn.de
More information about the Kde-bindings
mailing list