-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix handling of self-referential amf3 objects
This fixes some instances of the "failed to get object" panic in ruffle by no longer trying to handle value cycles Now all object values are tagged with an ObjectId and the new Value::Amf3ObjectReference's refer back to this so consumers can choose how to handle cycles (e.g. in Ruffles case, via the GC) Also moves raw-amf/byteobject tests into their own dir, adds a test for amf3 cycles and improves the lso-to-json tool to support bulk-test json recreation and generating raw-amf tests
- Loading branch information
Showing
87 changed files
with
271 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/// A locally unique identifier for an Amf3 object | ||
/// See the comment on `Value::Amf3ObjectReference` for details | ||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] | ||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] | ||
pub struct ObjectId(pub i64); | ||
|
||
impl ObjectId { | ||
/// An invalid object id | ||
/// | ||
/// Use this when the id of an object can't be known or will never need to be referenced (e.g. amf0) | ||
/// Unlike valid object id's, multiple objects with an `INVALID` id are explicitly allowed | ||
/// Attempting to write a reference to an invalid object id is illegal and may error | ||
/// Attempting to write an object with an invalid object id is allowed, but it cannot be referenced later | ||
pub const INVALID: Self = ObjectId(-1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"Object":[1,[{"name":"AAAA","value":{"Amf3ObjectReference":1}}],{"name":"","attributes":0,"static_properties":["AAAA"]}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
This file was generated with the following: | ||
|
||
let mut v = vec![]; | ||
let r = Rc::new(Value::Object(0, Vec::new().into(), Some(ClassDefinition { | ||
name: "".to_string(), | ||
attributes: Default::default(), | ||
static_properties: vec![], | ||
}))); | ||
|
||
let o = Value::Object(0, vec![ | ||
Element::new("AAAA", Rc::clone(&r)) | ||
].into(), Some(ClassDefinition { | ||
name: "".to_string(), | ||
attributes: Default::default(), | ||
static_properties: vec!["AAAA".to_string()], | ||
})); | ||
let oo = Rc::new(o); | ||
|
||
AMF3Encoder::default().write_value(&mut v, oo.as_ref()).unwrap(); | ||
v[9] = 0; | ||
v.pop(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"header":{"length":87,"name":"AS2-Array-Demo","format_version":"AMF0"},"body":[{"name":"myIntArray","value":{"ECMAArray":[[],[{"name":"0","value":{"Number":1.0}},{"name":"1","value":{"Number":2.0}},{"name":"2","value":{"Number":3.0}}],3]}}]} | ||
{"header":{"length":87,"name":"AS2-Array-Demo","format_version":"AMF0"},"body":[{"name":"myIntArray","value":{"ECMAArray":[[],[{"name":"0","value":{"Number":1.0}},{"name":"1","value":{"Number":2.0}},{"name":"2","value":{"Number":3.0}}],3]}}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"header":{"length":43,"name":"AS2-Boolean-Demo","format_version":"AMF0"},"body":[{"name":"myBool","value":{"Bool":true}}]} | ||
{"header":{"length":43,"name":"AS2-Boolean-Demo","format_version":"AMF0"},"body":[{"name":"myBool","value":{"Bool":true}}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"header":{"length":49,"name":"AS2-Date-Demo","format_version":"AMF0"},"body":[{"name":"myDate","value":{"Date":[1409653383774.0,240]}}]} | ||
{"header":{"length":49,"name":"AS2-Date-Demo","format_version":"AMF0"},"body":[{"name":"myDate","value":{"Date":[1409653383774.0,240]}}]} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"header":{"length":49,"name":"AS2-Integer-Demo","format_version":"AMF0"},"body":[{"name":"myInt","value":{"Number":7.0}}]} | ||
{"header":{"length":49,"name":"AS2-Integer-Demo","format_version":"AMF0"},"body":[{"name":"myInt","value":{"Number":7.0}}]} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"header":{"length":39,"name":"AS2-Null-Demo","format_version":"AMF0"},"body":[{"name":"myNull","value":"Null"}]} | ||
{"header":{"length":39,"name":"AS2-Null-Demo","format_version":"AMF0"},"body":[{"name":"myNull","value":"Null"}]} |
Oops, something went wrong.