Explorar o código

Fix runtime JS parsing crash on invalid codepoint on Raw binary property (#468)

Pavel Alexandrov %!s(int64=6) %!d(string=hai) anos
pai
achega
6b0d2868c7
Modificáronse 2 ficheiros con 16 adicións e 1 borrados
  1. 9 0
      hxd/fmt/fbx/Data.hx
  2. 7 1
      hxd/fmt/fbx/Parser.hx

+ 9 - 0
hxd/fmt/fbx/Data.hx

@@ -7,6 +7,7 @@ enum FbxProp {
 	PIdent( i : String );
 	PIdent( i : String );
 	PInts( v : Array<Int> );
 	PInts( v : Array<Int> );
 	PFloats( v : Array<Float> );
 	PFloats( v : Array<Float> );
+	PBinary( v : haxe.io.Bytes );
 }
 }
 
 
 typedef FbxNode = {
 typedef FbxNode = {
@@ -128,6 +129,14 @@ class FbxTools {
 		}
 		}
 	}
 	}
 
 
+	public static function toBinary( n : FbxProp ) {
+		if ( n == null ) throw "null prop";
+		return switch( n ) {
+		case PBinary(v): v;
+		default: throw "Invalid prop " + n;
+		}
+	}
+
 	public static function getId( n : FbxNode ) {
 	public static function getId( n : FbxNode ) {
 		if( n.props.length != 3 )
 		if( n.props.length != 3 )
 			throw n.name + " is not an object";
 			throw n.name + " is not an object";

+ 7 - 1
hxd/fmt/fbx/Parser.hx

@@ -300,11 +300,17 @@ class Parser {
 					arrayLen--;
 					arrayLen--;
 				}
 				}
 				return PInts(bools);
 				return PInts(bools);
-			case 'S'.code, 'R'.code:
+			case 'S'.code:
 				var len:Int = getInt32();
 				var len:Int = getInt32();
 				var s:String = bytes.getString(pos, len);
 				var s:String = bytes.getString(pos, len);
 				pos += len;
 				pos += len;
 				return PString(s);
 				return PString(s);
+			case 'R'.code:
+				var len:Int = getInt32();
+				var data = Bytes.alloc(len);
+				data.blit(0, bytes, pos, len);
+				pos += len;
+				return PBinary(data);
 			default:
 			default:
 				return error("Unknown property type: " + type + "/" + String.fromCharCode(type));
 				return error("Unknown property type: " + type + "/" + String.fromCharCode(type));
 		}
 		}