[xiph-commits] r8310 - in trunk/oggdsf/src: lib/codecs/cmml/libWinCMMLParse tests/testCMMLParser

illiminable at motherfish-iii.xiph.org illiminable at motherfish-iii.xiph.org
Tue Nov 30 00:37:04 PST 2004


Author: illiminable
Date: 2004-11-30 00:37:03 -0800 (Tue, 30 Nov 2004)
New Revision: 8310

Modified:
   trunk/oggdsf/src/lib/codecs/cmml/libWinCMMLParse/CMMLParser.cpp
   trunk/oggdsf/src/tests/testCMMLParser/testCMMLParser.cpp
Log:
* Removed crash on invalid cmml head text.

Modified: trunk/oggdsf/src/lib/codecs/cmml/libWinCMMLParse/CMMLParser.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/cmml/libWinCMMLParse/CMMLParser.cpp	2004-11-30 08:13:54 UTC (rev 8309)
+++ trunk/oggdsf/src/lib/codecs/cmml/libWinCMMLParse/CMMLParser.cpp	2004-11-30 08:37:03 UTC (rev 8310)
@@ -414,16 +414,15 @@
 	MSXML2::IXMLDOMDocument* locXMLHeadFrag = NULL;
 	MSXML2::IXMLDOMNode* locHeadNode  = NULL;
 		
-	setupXMLHandles(inHeadText, &locXMLHeadFrag);
-	//Validate
+	bool retVal = setupXMLHandles(inHeadText, &locXMLHeadFrag);
 
-	//locXMLClipFrag->selectSingleNode(locBStr, &locClipNode);
-	locHeadNode = getNamedNode(L"head", locXMLHeadFrag);
-	//Check return
+	if (retVal) {
+		locHeadNode = getNamedNode(L"head", locXMLHeadFrag);
+		//Check return
 
-	//Now we have a node representing the clip tag and it's children.
-	
-	bool retVal = parseHeadTag(locHeadNode, outHead);
+		//Now we have a node representing the clip tag and it's children.
+		retVal = parseHeadTag(locHeadNode, outHead);
+	}
 
 	if (locXMLHeadFrag != NULL)					locXMLHeadFrag->Release();
 	if (locHeadNode != NULL)					locHeadNode->Release();

Modified: trunk/oggdsf/src/tests/testCMMLParser/testCMMLParser.cpp
===================================================================
--- trunk/oggdsf/src/tests/testCMMLParser/testCMMLParser.cpp	2004-11-30 08:13:54 UTC (rev 8309)
+++ trunk/oggdsf/src/tests/testCMMLParser/testCMMLParser.cpp	2004-11-30 08:37:03 UTC (rev 8310)
@@ -9,24 +9,33 @@
 #include "CMMLParser.h"
 
 
-bool testHeadParse(wstring inHeadString, C_HeadTag* outHeadTag) {
+bool testHeadParse(wstring inHeadString) {
 	CMMLParser locParser;
-	return locParser.parseHeadTag(inHeadString, outHeadTag);
 
+	wcout << "Original"<<endl<<inHeadString<<endl<<endl;
+
+	C_HeadTag locHead;
+	
+	bool locWasOK = locParser.parseHeadTag(inHeadString, &locHead);
+
+	if (locWasOK) {
+		cout<<"Parsed OK"<<endl<<endl<<locHead.toString()<<endl<<endl;
+	} else {
+		cout<<"*** PARSE FAILED ***"<<endl<<endl;
+	}
+
+	return locWasOK;
 }
 
-int _tmain(int argc, _TCHAR* argv[])
+int __cdecl _tmain(int argc, _TCHAR* argv[])
 {
 
 	wstring head_1 = L"<head><title>Types of fish</title><meta name=\"Producer\" content=\"Joe Ordinary\"/><meta name=\"DC.Author\" content=\"Joe's friend\"/></head>";
+	testHeadParse(head_1);
 
-	wcout << "Original"<<endl<<head_1<<endl<<endl;
+	wstring head_2 = L"asdfasdfasdfasdf";
+	testHeadParse(head_2);
 
-	C_HeadTag locHead;
-	testHeadParse(head_1, &locHead);
-
-	cout<<"Parsed"<<endl<<locHead.toString()<<endl<<endl;
-
 	return 0;
 }
 



More information about the commits mailing list