Explorar o código

Try catch for corrupted Images

Fl0xer %!s(int64=7) %!d(string=hai) anos
pai
achega
c0eb73805f
Modificáronse 1 ficheiros con 2 adicións e 1 borrados
  1. 2 1
      hxd/res/Image.hx

+ 2 - 1
hxd/res/Image.hx

@@ -50,7 +50,8 @@ class Image extends Resource {
 			return inf;
 		var f = new hxd.fs.FileInput(entry);
 		var width = 0, height = 0, format;
-		switch( f.readUInt16() ) {
+		var head = try f.readUInt16() catch( e : haxe.io.Eof ) 0;
+		switch( head ) {
 		case 0xD8FF: // JPG
 			format = Jpg;
 			f.bigEndian = true;