Răsfoiți Sursa

added resource size limit to 12MB

Nicolas Cannasse 15 ani în urmă
părinte
comite
b9c16c5aaa
2 a modificat fișierele cu 9 adăugiri și 1 ștergeri
  1. 1 0
      doc/CHANGES.txt
  2. 8 1
      main.ml

+ 1 - 0
doc/CHANGES.txt

@@ -9,6 +9,7 @@
 	flash9 : list native getter/setters in Type API class/instance fields
 	all : make haxe.rtti.Generic typing lazy (fix for self-recursion)
 	all : allow haxe.rtti.Generic + inheritance
+	all : added resource size limit to 12MB (ocaml max_string_size is 16MB + b64)
 
 2010-01-09: 2.05
 	js : added js.Scroll

+ 8 - 1
main.ml

@@ -343,7 +343,14 @@ try
 				| _ -> raise (Arg.Bad "Invalid Resource format : should be file@name")
 			) in
 			let file = (try Common.find_file com file with Not_found -> file) in
-			let data = Std.input_file ~bin:true file in
+			let data = (try 
+				let s = Std.input_file ~bin:true file in
+				if String.length s > 12000000 then raise Exit;
+				s;
+			with 
+				| Sys_error _ -> failwith ("Resource file not found : " ^ file)
+				| _ -> failwith ("Resource '" ^ file ^ "' excess the maximum size of 12MB")
+			) in
 			if Hashtbl.mem com.resources name then failwith ("Duplicate resource name " ^ name);
 			Hashtbl.add com.resources name data
 		),"<file>[@name] : add a named resource file");