[xiph-commits] r8722 - in trunk/oggdsf/src/lib/codecs/cmml: libCMMLParse libCMMLTags

illiminable at motherfish-iii.xiph.org illiminable at motherfish-iii.xiph.org
Tue Jan 11 03:27:06 PST 2005


Author: illiminable
Date: 2005-01-11 03:27:06 -0800 (Tue, 11 Jan 2005)
New Revision: 8722

Modified:
   trunk/oggdsf/src/lib/codecs/cmml/libCMMLParse/CMMLParser.cpp
   trunk/oggdsf/src/lib/codecs/cmml/libCMMLTags/C_MappedTagList.cpp
Log:
* Add a check to the cmml parser to make sure the file is open so we don't try and allocate a huge chunk of mem.
* Fixed a bug in the mapped tag list which when you asked for the value of a key value pair, would just return you the key not the value. 
* Also added a check in the mapped tag list, so if the key doesn't exist we don't try and deref a null pointer.

Modified: trunk/oggdsf/src/lib/codecs/cmml/libCMMLParse/CMMLParser.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/cmml/libCMMLParse/CMMLParser.cpp	2005-01-11 09:18:55 UTC (rev 8721)
+++ trunk/oggdsf/src/lib/codecs/cmml/libCMMLParse/CMMLParser.cpp	2005-01-11 11:27:06 UTC (rev 8722)
@@ -70,9 +70,14 @@
 
 	fstream locFile;
 
-	locFile.open(StringHelper::toNarrowStr(inFilename).c_str(),
-		ios_base::in | ios_base::binary);
+	locFile.open(StringHelper::toNarrowStr(inFilename).c_str(), ios_base::in | ios_base::binary);
 
+	if (!locFile.is_open()) {
+		//Check if the file is actually open, else if it isn't tellg will return -1 as unsigned.
+		// and then we'll try to allocate 4 gigs of memory... which will probably fail :)
+		return false;
+	}
+
 	// Look ma, the world's most portable file-size-getting-function-thing
 	locFile.seekg(0, ios::end);
 	size_t locCMMLFileSize = locFile.tellg();

Modified: trunk/oggdsf/src/lib/codecs/cmml/libCMMLTags/C_MappedTagList.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/cmml/libCMMLTags/C_MappedTagList.cpp	2005-01-11 09:18:55 UTC (rev 8721)
+++ trunk/oggdsf/src/lib/codecs/cmml/libCMMLTags/C_MappedTagList.cpp	2005-01-11 11:27:06 UTC (rev 8722)
@@ -89,7 +89,12 @@
 }
 
 wstring C_MappedTagList::getContent(wstring inName) {
-	return getTag(inName)->name();
+	C_MappedTag* locTag =  getTag(inName);
+	if (locTag != NULL) {
+		return locTag->content();
+	} else {
+		return L"";
+	}
 }
 
 wstring C_MappedTagList::toString() {



More information about the commits mailing list