When computing an 'and' Boolean statement, the compiler will stop processing
the condition as soon as the first false is found, since it will immediately
cause the entire statement to be false.  So, if rf == 0, then the second
condition won't be evaluated.  The same rule applies to 'or', if a true
condition is found, the others are ignored and the conditional returns true.

 

  _____  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Alan Purvis
Sent: Wednesday, November 29, 2006 9:40 AM
To: osg users
Subject: [osg-users] Possible bug in osgDB::Registry::ReadObject()

 

Hi,

 

While attempting to track down the oddity I posted earlier about loading
GLSL programs from .osg files, I've been digging around the source for the
.osg loading mechanism (It has taken a while but I think I've finally gotten
my head around how the code works), I spotted what I believe to be a
potentially fatal bug on line 890 of osgDB::Registry.cpp in the v1.2 source.

 

The line and its previous read:

 

[889] DotOsgWrapper::ReadFunc rf = mitr->second->getReadFunc();

[890] if (rf && (*rf)(*obj,fr)) iteratorAdvanced = true;

 

In the event the function pointer rf is set to NULL on line 889; I believe
the if statement on the next line will cause a null pointer dereference.
Should this not be written as:

 

[890] if (rf) if ((*rf)(*obj,fr)) iteratorAdvanced = true;

 

...in order to protect from this problem?

 

Alan.

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to