[Swfdec-commits] 4 commits - swfdec/swfdec_as_interpret.c test/trace

Benjamin Otte company at kemper.freedesktop.org
Wed Mar 26 02:15:40 PDT 2008


 swfdec/swfdec_as_interpret.c                    |   24 +-------
 test/trace/Makefile.am                          |   31 ++++++++++
 test/trace/constantpool-broken-5.swf            |binary
 test/trace/constantpool-broken-5.swf.trace      |   12 ++++
 test/trace/constantpool-broken-5.swf.trace.org  |   12 ++++
 test/trace/constantpool-broken-6.swf            |binary
 test/trace/constantpool-broken-6.swf.trace      |   12 ++++
 test/trace/constantpool-broken-6.swf.trace.org  |   12 ++++
 test/trace/constantpool-broken-7.swf            |binary
 test/trace/constantpool-broken-7.swf.trace      |   12 ++++
 test/trace/constantpool-broken-7.swf.trace.org  |   12 ++++
 test/trace/constantpool-broken-8.swf            |binary
 test/trace/constantpool-broken-8.swf.trace      |   12 ++++
 test/trace/constantpool-broken-8.swf.trace.org  |   12 ++++
 test/trace/constantpool-broken.xml              |   60 ++++++++++++++++++++
 test/trace/constantpool-functions-5.swf         |binary
 test/trace/constantpool-functions-5.swf.trace   |    5 +
 test/trace/constantpool-functions-6.swf         |binary
 test/trace/constantpool-functions-6.swf.trace   |    5 +
 test/trace/constantpool-functions-7.swf         |binary
 test/trace/constantpool-functions-7.swf.trace   |    5 +
 test/trace/constantpool-functions-8.swf         |binary
 test/trace/constantpool-functions-8.swf.trace   |    5 +
 test/trace/constantpool-functions.xml           |   72 ++++++++++++++++++++++++
 test/trace/constantpool-when-lookup-5.swf       |binary
 test/trace/constantpool-when-lookup-5.swf.trace |    2 
 test/trace/constantpool-when-lookup-6.swf       |binary
 test/trace/constantpool-when-lookup-6.swf.trace |    2 
 test/trace/constantpool-when-lookup-7.swf       |binary
 test/trace/constantpool-when-lookup-7.swf.trace |    2 
 test/trace/constantpool-when-lookup-8.swf       |binary
 test/trace/constantpool-when-lookup-8.swf.trace |    2 
 test/trace/constantpool-when-lookup.xml         |   40 +++++++++++++
 33 files changed, 332 insertions(+), 19 deletions(-)

New commits:
commit e6661895392a4f6e068c96a514677ae6ccedbf25
Author: Benjamin Otte <otte at gnome.org>
Date:   Wed Mar 26 10:14:37 2008 +0100

    add a test that checks when constant pool values are looked up

diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 42c560d..4664e79 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -576,6 +576,15 @@ EXTRA_DIST = \
 	constantpool-functions-8.swf \
 	constantpool-functions-8.swf.trace \
 	constantpool-functions.xml \
+	constantpool-when-lookup-5.swf \
+	constantpool-when-lookup-5.swf.trace \
+	constantpool-when-lookup-6.swf \
+	constantpool-when-lookup-6.swf.trace \
+	constantpool-when-lookup-7.swf \
+	constantpool-when-lookup-7.swf.trace \
+	constantpool-when-lookup-8.swf \
+	constantpool-when-lookup-8.swf.trace \
+	constantpool-when-lookup.xml \
 	construct-constructors.as \
 	construct-constructors-5.swf \
 	construct-constructors-5.swf.trace \
diff --git a/test/trace/constantpool-when-lookup-5.swf b/test/trace/constantpool-when-lookup-5.swf
new file mode 100644
index 0000000..6a74122
Binary files /dev/null and b/test/trace/constantpool-when-lookup-5.swf differ
diff --git a/test/trace/constantpool-when-lookup-5.swf.trace b/test/trace/constantpool-when-lookup-5.swf.trace
new file mode 100644
index 0000000..3bd1f0e
--- /dev/null
+++ b/test/trace/constantpool-when-lookup-5.swf.trace
@@ -0,0 +1,2 @@
+foo
+bar
diff --git a/test/trace/constantpool-when-lookup-6.swf b/test/trace/constantpool-when-lookup-6.swf
new file mode 100644
index 0000000..4bb4498
Binary files /dev/null and b/test/trace/constantpool-when-lookup-6.swf differ
diff --git a/test/trace/constantpool-when-lookup-6.swf.trace b/test/trace/constantpool-when-lookup-6.swf.trace
new file mode 100644
index 0000000..3bd1f0e
--- /dev/null
+++ b/test/trace/constantpool-when-lookup-6.swf.trace
@@ -0,0 +1,2 @@
+foo
+bar
diff --git a/test/trace/constantpool-when-lookup-7.swf b/test/trace/constantpool-when-lookup-7.swf
new file mode 100644
index 0000000..5a6ebe4
Binary files /dev/null and b/test/trace/constantpool-when-lookup-7.swf differ
diff --git a/test/trace/constantpool-when-lookup-7.swf.trace b/test/trace/constantpool-when-lookup-7.swf.trace
new file mode 100644
index 0000000..3bd1f0e
--- /dev/null
+++ b/test/trace/constantpool-when-lookup-7.swf.trace
@@ -0,0 +1,2 @@
+foo
+bar
diff --git a/test/trace/constantpool-when-lookup-8.swf b/test/trace/constantpool-when-lookup-8.swf
new file mode 100644
index 0000000..7b1e28f
Binary files /dev/null and b/test/trace/constantpool-when-lookup-8.swf differ
diff --git a/test/trace/constantpool-when-lookup-8.swf.trace b/test/trace/constantpool-when-lookup-8.swf.trace
new file mode 100644
index 0000000..3bd1f0e
--- /dev/null
+++ b/test/trace/constantpool-when-lookup-8.swf.trace
@@ -0,0 +1,2 @@
+foo
+bar
diff --git a/test/trace/constantpool-when-lookup.xml b/test/trace/constantpool-when-lookup.xml
new file mode 100644
index 0000000..50bc299
--- /dev/null
+++ b/test/trace/constantpool-when-lookup.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0"?>
+<swf version="7" compressed="1">
+  <Header framerate="1" frames="1">
+    <size>
+      <Rectangle left="0" right="4000" top="0" bottom="3000"/>
+    </size>
+    <tags>
+      <DoAction>
+        <actions>
+          <Dictionary>
+            <strings>
+              <String value="foo"/>
+            </strings>
+          </Dictionary>
+	  <PushData>
+	    <items>
+	      <StackDictionaryLookup index="0"/>
+	    </items>
+	  </PushData>
+          <Dictionary>
+            <strings>
+              <String value="bar"/>
+            </strings>
+          </Dictionary>
+	  <Trace/>
+	  <PushData>
+	    <items>
+	      <StackDictionaryLookup index="0"/>
+	    </items>
+	  </PushData>
+	  <Trace/>
+	  <GetURL url="fscommand:quit" target=""/>
+          <EndAction/>
+        </actions>
+      </DoAction>
+      <ShowFrame/>
+      <End/>
+    </tags>
+  </Header>
+</swf>
commit 106d30562f770fccbea28aaba4fd9799fe8f69fc
Author: Benjamin Otte <otte at gnome.org>
Date:   Wed Mar 26 10:11:08 2008 +0100

    add test for constant pool redefinitions in functions

diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index e43c7ac..42c560d 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -567,6 +567,15 @@ EXTRA_DIST = \
 	constantpool-broken-8.swf.trace \
 	constantpool-broken-8.swf.trace.org \
 	constantpool-broken.xml \
+	constantpool-functions-5.swf \
+	constantpool-functions-5.swf.trace \
+	constantpool-functions-6.swf \
+	constantpool-functions-6.swf.trace \
+	constantpool-functions-7.swf \
+	constantpool-functions-7.swf.trace \
+	constantpool-functions-8.swf \
+	constantpool-functions-8.swf.trace \
+	constantpool-functions.xml \
 	construct-constructors.as \
 	construct-constructors-5.swf \
 	construct-constructors-5.swf.trace \
diff --git a/test/trace/constantpool-functions-5.swf b/test/trace/constantpool-functions-5.swf
new file mode 100644
index 0000000..2a32891
Binary files /dev/null and b/test/trace/constantpool-functions-5.swf differ
diff --git a/test/trace/constantpool-functions-5.swf.trace b/test/trace/constantpool-functions-5.swf.trace
new file mode 100644
index 0000000..379ee20
--- /dev/null
+++ b/test/trace/constantpool-functions-5.swf.trace
@@ -0,0 +1,5 @@
+foo
+baz
+foo
+baz
+bar
diff --git a/test/trace/constantpool-functions-6.swf b/test/trace/constantpool-functions-6.swf
new file mode 100644
index 0000000..e1b813a
Binary files /dev/null and b/test/trace/constantpool-functions-6.swf differ
diff --git a/test/trace/constantpool-functions-6.swf.trace b/test/trace/constantpool-functions-6.swf.trace
new file mode 100644
index 0000000..379ee20
--- /dev/null
+++ b/test/trace/constantpool-functions-6.swf.trace
@@ -0,0 +1,5 @@
+foo
+baz
+foo
+baz
+bar
diff --git a/test/trace/constantpool-functions-7.swf b/test/trace/constantpool-functions-7.swf
new file mode 100644
index 0000000..5c3b70d
Binary files /dev/null and b/test/trace/constantpool-functions-7.swf differ
diff --git a/test/trace/constantpool-functions-7.swf.trace b/test/trace/constantpool-functions-7.swf.trace
new file mode 100644
index 0000000..379ee20
--- /dev/null
+++ b/test/trace/constantpool-functions-7.swf.trace
@@ -0,0 +1,5 @@
+foo
+baz
+foo
+baz
+bar
diff --git a/test/trace/constantpool-functions-8.swf b/test/trace/constantpool-functions-8.swf
new file mode 100644
index 0000000..7c8b5ea
Binary files /dev/null and b/test/trace/constantpool-functions-8.swf differ
diff --git a/test/trace/constantpool-functions-8.swf.trace b/test/trace/constantpool-functions-8.swf.trace
new file mode 100644
index 0000000..379ee20
--- /dev/null
+++ b/test/trace/constantpool-functions-8.swf.trace
@@ -0,0 +1,5 @@
+foo
+baz
+foo
+baz
+bar
diff --git a/test/trace/constantpool-functions.xml b/test/trace/constantpool-functions.xml
new file mode 100644
index 0000000..4706fbc
--- /dev/null
+++ b/test/trace/constantpool-functions.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0"?>
+<swf version="7" compressed="1">
+  <Header framerate="1" frames="1">
+    <size>
+      <Rectangle left="0" right="4000" top="0" bottom="3000"/>
+    </size>
+    <tags>
+      <DoAction>
+        <actions>
+          <Dictionary>
+            <strings>
+              <String value="foo"/>
+            </strings>
+          </Dictionary>
+	  <DeclareFunction2 name="foo">
+            <args/>
+            <actions>
+              <PushData>
+                <items>
+                  <StackDictionaryLookup index="0"/>
+                </items>
+              </PushData>
+              <Trace/>
+	      <Dictionary>
+		<strings>
+		  <String value="baz"/>
+		</strings>
+	      </Dictionary>
+              <PushData>
+                <items>
+                  <StackDictionaryLookup index="0"/>
+                </items>
+              </PushData>
+              <Trace/>
+            </actions>
+          </DeclareFunction2>
+          <PushData>
+            <items>
+              <StackInteger value="0"/>
+              <StackDictionaryLookup index="0"/>
+            </items>
+          </PushData>
+          <CallFunction/>
+          <Pop/>
+          <Dictionary>
+            <strings>
+              <String value="bar"/>
+            </strings>
+          </Dictionary>
+          <PushData>
+            <items>
+              <StackInteger value="0"/>
+              <StackString value="foo"/>
+            </items>
+          </PushData>
+          <CallFunction/>
+          <Pop/>
+	  <PushData>
+	    <items>
+	      <StackDictionaryLookup index="0"/>
+	    </items>
+	  </PushData>
+	  <Trace/>
+	  <GetURL url="fscommand:quit" target=""/>
+          <EndAction/>
+        </actions>
+      </DoAction>
+      <ShowFrame/>
+      <End/>
+    </tags>
+  </Header>
+</swf>
commit 546c93516dd9a71f10671c3d06a77ce11f1d6eb2
Author: Benjamin Otte <otte at gnome.org>
Date:   Wed Mar 26 10:07:43 2008 +0100

    add a test for broken constant pools

diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 8e55a2b..e43c7ac 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -554,6 +554,19 @@ EXTRA_DIST = \
 	comparisons-6.swf.trace \
 	comparisons-7.swf \
 	comparisons-7.swf.trace \
+	constantpool-broken-5.swf \
+	constantpool-broken-5.swf.trace \
+	constantpool-broken-5.swf.trace.org \
+	constantpool-broken-6.swf \
+	constantpool-broken-6.swf.trace \
+	constantpool-broken-6.swf.trace.org \
+	constantpool-broken-7.swf \
+	constantpool-broken-7.swf.trace \
+	constantpool-broken-7.swf.trace.org \
+	constantpool-broken-8.swf \
+	constantpool-broken-8.swf.trace \
+	constantpool-broken-8.swf.trace.org \
+	constantpool-broken.xml \
 	construct-constructors.as \
 	construct-constructors-5.swf \
 	construct-constructors-5.swf.trace \
diff --git a/test/trace/constantpool-broken-5.swf b/test/trace/constantpool-broken-5.swf
new file mode 100644
index 0000000..d99e57c
Binary files /dev/null and b/test/trace/constantpool-broken-5.swf differ
diff --git a/test/trace/constantpool-broken-5.swf.trace b/test/trace/constantpool-broken-5.swf.trace
new file mode 100644
index 0000000..98bebdb
--- /dev/null
+++ b/test/trace/constantpool-broken-5.swf.trace
@@ -0,0 +1,12 @@
+undefined
+24
+undefined
+undefined
+undefined
+undefined
+1
+undefined
+foo
+undefined
+undefined
+42
diff --git a/test/trace/constantpool-broken-5.swf.trace.org b/test/trace/constantpool-broken-5.swf.trace.org
new file mode 100644
index 0000000..7e7bcf8
--- /dev/null
+++ b/test/trace/constantpool-broken-5.swf.trace.org
@@ -0,0 +1,12 @@
+1.70690204121556e-39
+
+d
+21
+undefined
+undefined
+1
+undefined
+foo
+undefined
+0
+42
diff --git a/test/trace/constantpool-broken-6.swf b/test/trace/constantpool-broken-6.swf
new file mode 100644
index 0000000..cbf83c3
Binary files /dev/null and b/test/trace/constantpool-broken-6.swf differ
diff --git a/test/trace/constantpool-broken-6.swf.trace b/test/trace/constantpool-broken-6.swf.trace
new file mode 100644
index 0000000..98bebdb
--- /dev/null
+++ b/test/trace/constantpool-broken-6.swf.trace
@@ -0,0 +1,12 @@
+undefined
+24
+undefined
+undefined
+undefined
+undefined
+1
+undefined
+foo
+undefined
+undefined
+42
diff --git a/test/trace/constantpool-broken-6.swf.trace.org b/test/trace/constantpool-broken-6.swf.trace.org
new file mode 100644
index 0000000..7e7bcf8
--- /dev/null
+++ b/test/trace/constantpool-broken-6.swf.trace.org
@@ -0,0 +1,12 @@
+1.70690204121556e-39
+
+d
+21
+undefined
+undefined
+1
+undefined
+foo
+undefined
+0
+42
diff --git a/test/trace/constantpool-broken-7.swf b/test/trace/constantpool-broken-7.swf
new file mode 100644
index 0000000..3e18689
Binary files /dev/null and b/test/trace/constantpool-broken-7.swf differ
diff --git a/test/trace/constantpool-broken-7.swf.trace b/test/trace/constantpool-broken-7.swf.trace
new file mode 100644
index 0000000..98bebdb
--- /dev/null
+++ b/test/trace/constantpool-broken-7.swf.trace
@@ -0,0 +1,12 @@
+undefined
+24
+undefined
+undefined
+undefined
+undefined
+1
+undefined
+foo
+undefined
+undefined
+42
diff --git a/test/trace/constantpool-broken-7.swf.trace.org b/test/trace/constantpool-broken-7.swf.trace.org
new file mode 100644
index 0000000..7e7bcf8
--- /dev/null
+++ b/test/trace/constantpool-broken-7.swf.trace.org
@@ -0,0 +1,12 @@
+1.70690204121556e-39
+
+d
+21
+undefined
+undefined
+1
+undefined
+foo
+undefined
+0
+42
diff --git a/test/trace/constantpool-broken-8.swf b/test/trace/constantpool-broken-8.swf
new file mode 100644
index 0000000..a65c106
Binary files /dev/null and b/test/trace/constantpool-broken-8.swf differ
diff --git a/test/trace/constantpool-broken-8.swf.trace b/test/trace/constantpool-broken-8.swf.trace
new file mode 100644
index 0000000..98bebdb
--- /dev/null
+++ b/test/trace/constantpool-broken-8.swf.trace
@@ -0,0 +1,12 @@
+undefined
+24
+undefined
+undefined
+undefined
+undefined
+1
+undefined
+foo
+undefined
+undefined
+42
diff --git a/test/trace/constantpool-broken-8.swf.trace.org b/test/trace/constantpool-broken-8.swf.trace.org
new file mode 100644
index 0000000..7e7bcf8
--- /dev/null
+++ b/test/trace/constantpool-broken-8.swf.trace.org
@@ -0,0 +1,12 @@
+1.70690204121556e-39
+
+d
+21
+undefined
+undefined
+1
+undefined
+foo
+undefined
+0
+42
diff --git a/test/trace/constantpool-broken.xml b/test/trace/constantpool-broken.xml
new file mode 100644
index 0000000..082badd
--- /dev/null
+++ b/test/trace/constantpool-broken.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+<swf version="7" compressed="1">
+  <Header framerate="1" frames="1">
+    <size>
+      <Rectangle left="0" right="4000" top="0" bottom="3000"/>
+    </size>
+    <tags>
+      <DoAction>
+        <actions>
+	  <PushData>
+	    <items>
+	      <StackDictionaryLookup index="1"/>
+	    </items>
+	  </PushData>
+	  <Trace/>
+	  <PushData>
+	    <items>
+	      <StackInteger value="21"/>
+	      <StackDictionaryLookup index="0"/>
+	      <StackDictionaryLookup index="1"/>
+	      <StackDictionaryLookup index="5"/>
+	      <StackDictionaryLookup index="100"/>
+	      <StackInteger value="24"/>
+	    </items>
+	  </PushData>
+	  <Trace/>
+	  <Trace/>
+	  <Trace/>
+	  <Trace/>
+	  <Trace/>
+          <Dictionary>
+            <strings>
+              <String value="foo"/>
+            </strings>
+          </Dictionary>
+	  <PushData>
+	    <items>
+	      <StackInteger value="42"/>
+	      <StackDictionaryLookup index="1"/>
+	      <StackDictionaryLookup index="5"/>
+	      <StackDictionaryLookup index="0"/>
+	      <StackDictionaryLookup index="100"/>
+	      <StackInteger value="1"/>
+	    </items>
+	  </PushData>
+	  <Trace/>
+	  <Trace/>
+	  <Trace/>
+	  <Trace/>
+	  <Trace/>
+	  <Trace/>
+	  <GetURL url="fscommand:quit" target=""/>
+	  <EndAction/>
+        </actions>
+      </DoAction>
+      <ShowFrame/>
+      <End/>
+    </tags>
+  </Header>
+</swf>
commit fbe9335483f906e7b2b01da4999f1663540cb758
Author: Benjamin Otte <otte at gnome.org>
Date:   Wed Mar 26 10:02:42 2008 +0100

    push undefined on ConstantPool error instead of aborting

diff --git a/swfdec/swfdec_as_interpret.c b/swfdec/swfdec_as_interpret.c
index 3544a1b..e4bfd9a 100644
--- a/swfdec/swfdec_as_interpret.c
+++ b/swfdec/swfdec_as_interpret.c
@@ -356,34 +356,20 @@ swfdec_action_push (SwfdecAsContext *cx, guint action, const guint8 *data, guint
 	    (int) swfdec_bits_get_u32 (&bits));
 	break;
       case 8: /* 8bit ConstantPool address */
-	{
-	  guint i = swfdec_bits_get_u8 (&bits);
-	  SwfdecConstantPool *pool = cx->frame->constant_pool;
-	  if (pool == NULL) {
-	    SWFDEC_ERROR ("no constant pool to push from");
-	    return;
-	  }
-	  if (i >= swfdec_constant_pool_size (pool)) {
-	    SWFDEC_ERROR ("constant pool index %u too high - only %u elements",
-		i, swfdec_constant_pool_size (pool));
-	    return;
-	  }
-	  SWFDEC_AS_VALUE_SET_STRING (swfdec_as_stack_push (cx), 
-	      swfdec_constant_pool_get (pool, i));
-	  break;
-	}
       case 9: /* 16bit ConstantPool address */
 	{
-	  guint i = swfdec_bits_get_u16 (&bits);
+	  guint i = type == 8 ? swfdec_bits_get_u8 (&bits) : swfdec_bits_get_u16 (&bits);
 	  SwfdecConstantPool *pool = cx->frame->constant_pool;
 	  if (pool == NULL) {
 	    SWFDEC_ERROR ("no constant pool to push from");
-	    return;
+	    SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_push (cx));
+	    break;
 	  }
 	  if (i >= swfdec_constant_pool_size (pool)) {
 	    SWFDEC_ERROR ("constant pool index %u too high - only %u elements",
 		i, swfdec_constant_pool_size (pool));
-	    return;
+	    SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_push (cx));
+	    break;
 	  }
 	  SWFDEC_AS_VALUE_SET_STRING (swfdec_as_stack_push (cx), 
 	      swfdec_constant_pool_get (pool, i));


More information about the Swfdec-commits mailing list