2
0
Эх сурвалжийг харах

Change string validation to suit the new binary layout.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@607 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
aramis_acg 15 жил өмнө
parent
commit
46d56ff619

+ 8 - 3
code/ValidateDataStructure.cpp

@@ -663,13 +663,18 @@ void ValidateDSProcess::Validate( const aiMaterial* pMaterial)
 		}
 		// check all predefined types
 		if (aiPTI_String == prop->mType)	{
-			// FIX: strings are now stored in a less expensive way ...
-			if (prop->mDataLength < 5 || prop->mDataLength < 4 + *reinterpret_cast<uint32_t*>(prop->mData) + 1)	{
+			// FIX: strings are now stored in a less expensive way, but we can't use the
+			// validation routine for 'normal' aiStrings
+			uint32_t len;
+			if (prop->mDataLength < 5 || prop->mDataLength < 4 + (len=*reinterpret_cast<uint32_t*>(prop->mData)) + 1)	{
 				ReportError("aiMaterial::mProperties[%i].mDataLength is "
 					"too small to contain a string (%i, needed: %i)",
 					i,prop->mDataLength,sizeof(aiString));
 			}
-			Validate((const aiString*)prop->mData);
+			if(prop->mData[prop->mDataLength-1]) {
+				ReportError("Missing null-terminator in string material property");
+			}
+		//	Validate((const aiString*)prop->mData);
 		}
 		else if (aiPTI_Float == prop->mType)	{
 			if (prop->mDataLength < sizeof(float))	{