[commit] r1088 - trunk/GME/Core

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Wed Nov 17 15:28:50 CST 2010


Author: ksmyth
Date: Wed Nov 17 15:28:50 2010
New Revision: 1088

Log:
Throwing std::bad_alloc causes GME to crash. COMTHROW instead

Modified:
   trunk/GME/Core/CoreBinFile.cpp

Modified: trunk/GME/Core/CoreBinFile.cpp
==============================================================================
--- trunk/GME/Core/CoreBinFile.cpp	Wed Nov 17 12:37:02 2010	(r1087)
+++ trunk/GME/Core/CoreBinFile.cpp	Wed Nov 17 15:28:50 2010	(r1088)
@@ -532,7 +532,12 @@
 	if(ifs.eof()) COMTHROW(E_FILEOPEN);
 	ASSERT( len >= 0 );
 
-	b.resize(len);
+	try {
+		b.resize(len);
+	} catch (std::bad_alloc&) {
+		// KMS: could get here if the project is corrupt and len is incorrect
+		COMTHROW(E_OUTOFMEMORY);
+	}
 	if( len > 0 )
 		ifs.read( (char *) &b[0], len);
 }


More information about the gme-commit mailing list