[Scummvm-cvs-logs] CVS: tools descumm-tool.cpp,1.10,1.11 descumm6.cpp,1.187,1.188

Max Horn fingolfin at users.sourceforge.net
Sat Jun 4 14:01:13 CEST 2005


Update of /cvsroot/scummvm/tools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19961

Modified Files:
	descumm-tool.cpp descumm6.cpp 
Log Message:
Fix crashes with big COMI scripts

Index: descumm-tool.cpp
===================================================================
RCS file: /cvsroot/scummvm/tools/descumm-tool.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- descumm-tool.cpp	1 Jan 2005 10:33:30 -0000	1.10
+++ descumm-tool.cpp	4 Jun 2005 21:00:50 -0000	1.11
@@ -22,6 +22,10 @@
 
 #include "descumm.h"
 
+// 200kb limit on the input file (we just read it all at once into memory).
+// Should be no problem, the biggest scripts I have seen were in COMI and
+// went up to 180kb (script-457).
+#define MAX_FILE_SIZE (200 * 1024)
 
 void ShowHelpAndExit()
 {
@@ -254,8 +258,8 @@
 		return 1;
 	}
 
-	memorg = mem = (byte *)malloc(65536);
-	len = fread(mem, 1, 65536, in);
+	memorg = mem = (byte *)malloc(MAX_FILE_SIZE);
+	len = fread(mem, 1, MAX_FILE_SIZE, in);
 	fclose(in);
 	size_of_code = len;
 

Index: descumm6.cpp
===================================================================
RCS file: /cvsroot/scummvm/tools/descumm6.cpp,v
retrieving revision 1.187
retrieving revision 1.188
diff -u -d -r1.187 -r1.188
--- descumm6.cpp	28 May 2005 13:24:18 -0000	1.187
+++ descumm6.cpp	4 Jun 2005 21:00:50 -0000	1.188
@@ -116,7 +116,8 @@
 	"%"
 };
 
-static StackEnt *stack[128];
+#define MAX_STACK_SIZE	256
+static StackEnt *stack[MAX_STACK_SIZE];
 static int num_stack = 0;
 bool HumongousFlag = false;
 
@@ -789,6 +790,7 @@
 void push(StackEnt * se)
 {
 	assert(se);
+	assert(num_stack < MAX_STACK_SIZE);
 	stack[num_stack++] = se;
 }
 





More information about the Scummvm-git-logs mailing list