bug in ScriptTranslator::getConstantType ?

Minor issues with the Ogre API that can be trivial to fix
Crashy
Google Summer of Code Student
Google Summer of Code Student
Posts: 1005
Joined: Wed Jan 08, 2003 9:15 pm
Location: Lyon, France
x 49

bug in ScriptTranslator::getConstantType ?

Post by Crashy »

Hi, I just encountered a bug in ScriptTranslator::getConstantType, Ogre 1.7.1.

When using matrix shared parameters, it falls into this piece of code:

Code: Select all

else if(val.find("matrix") != String::npos)
		{
			int count1, count2;

			if (val.size() == 9)
			{
				count1 = StringConverter::parseInt(val.substr(6, 1));
				count2 = StringConverter::parseInt(val.substr(8, 1));
			}
			else 
				return false;

			if (count1 > 4 || count1 < 2 || count2 > 4 || count2 < 2)
				return false;

			switch(count1)
			{
			case 2:
				*op = (GpuConstantType)(GCT_MATRIX_2X2 + count2 - 1);
				break;
			case 3:
				*op = (GpuConstantType)(GCT_MATRIX_3X2 + count2 - 1);
				break;
			case 4:
				*op = (GpuConstantType)(GCT_MATRIX_4X2 + count2 - 1);
				break;
			}

		}
The fact is that count2 is a value between 2 and 4, so it shouldn't be count2-1 but count2-2.
I don't know it it has been resolved in current developpement version of Ogre, but currently it results of a bad estimation of the size of the parameter and a crash when setting a value to the parameter.

I created a report in the bugtracker.
Last edited by spacegaier on Sat Jan 29, 2011 3:56 pm, edited 3 times in total.
Reason: linked to the tracker item
Follow la Moustache on Twitter or on Facebook
Image
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58

Re: bug in ScriptTranslator::getConstantType ?

Post by CABAListic »

This issue is already fixed in v1.7.2.