[Swfdec] 4 commits - libswfdec/swfdec_as_interpret.c libswfdec/swfdec_sound.c test/trace
Benjamin Otte
company at kemper.freedesktop.org
Sun Oct 14 06:06:25 PDT 2007
libswfdec/swfdec_as_interpret.c | 88 +++++++++++++++------------
libswfdec/swfdec_sound.c | 8 ++
test/trace/Makefile.am | 9 ++
test/trace/getsetproperty-target-5.swf |binary
test/trace/getsetproperty-target-5.swf.trace | 6 +
test/trace/getsetproperty-target-6.swf |binary
test/trace/getsetproperty-target-6.swf.trace | 6 +
test/trace/getsetproperty-target-7.swf |binary
test/trace/getsetproperty-target-7.swf.trace | 6 +
test/trace/getsetproperty-target-8.swf |binary
test/trace/getsetproperty-target-8.swf.trace | 6 +
test/trace/getsetproperty-target.as | 34 ++++++++++
12 files changed, 124 insertions(+), 39 deletions(-)
New commits:
commit 04c37ddd61e7e3f899e1f5dc534acf2630538b3f
Merge: c7fcc86... 5272df3...
Author: Benjamin Otte <otte at gnome.org>
Date: Sun Oct 14 15:02:30 2007 +0200
Merge branch 'master' of ssh://company@git.freedesktop.org/git/swfdec/swfdec
commit c7fcc86ae0097fe4071520f66b4470f3820dc6fc
Author: Benjamin Otte <otte at gnome.org>
Date: Sun Oct 14 15:02:02 2007 +0200
add test for Get/SetProperty actions
Not a very complete test, but it used to fail ;)
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index d20beb2..33cc77d 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -590,6 +590,15 @@ EXTRA_DIST = \
forin-delete-6.swf.trace \
forin-delete-7.swf \
forin-delete-7.swf.trace \
+ getsetproperty-target.as \
+ getsetproperty-target-5.swf \
+ getsetproperty-target-5.swf.trace \
+ getsetproperty-target-6.swf \
+ getsetproperty-target-6.swf.trace \
+ getsetproperty-target-7.swf \
+ getsetproperty-target-7.swf.trace \
+ getsetproperty-target-8.swf \
+ getsetproperty-target-8.swf.trace \
getvariable-delimiters.as \
getvariable-delimiters-5.swf \
getvariable-delimiters-5.swf.trace \
diff --git a/test/trace/getsetproperty-target-5.swf b/test/trace/getsetproperty-target-5.swf
new file mode 100644
index 0000000..8e87bec
Binary files /dev/null and b/test/trace/getsetproperty-target-5.swf differ
diff --git a/test/trace/getsetproperty-target-5.swf.trace b/test/trace/getsetproperty-target-5.swf.trace
new file mode 100644
index 0000000..6dfa5e7
--- /dev/null
+++ b/test/trace/getsetproperty-target-5.swf.trace
@@ -0,0 +1,6 @@
+undefined
+undefined
+undefined
+undefined
+/
+42
diff --git a/test/trace/getsetproperty-target-6.swf b/test/trace/getsetproperty-target-6.swf
new file mode 100644
index 0000000..ff143d4
Binary files /dev/null and b/test/trace/getsetproperty-target-6.swf differ
diff --git a/test/trace/getsetproperty-target-6.swf.trace b/test/trace/getsetproperty-target-6.swf.trace
new file mode 100644
index 0000000..91a3e10
--- /dev/null
+++ b/test/trace/getsetproperty-target-6.swf.trace
@@ -0,0 +1,6 @@
+/a/a
+42
+/a/a
+42
+/
+42
diff --git a/test/trace/getsetproperty-target-7.swf b/test/trace/getsetproperty-target-7.swf
new file mode 100644
index 0000000..fb06c28
Binary files /dev/null and b/test/trace/getsetproperty-target-7.swf differ
diff --git a/test/trace/getsetproperty-target-7.swf.trace b/test/trace/getsetproperty-target-7.swf.trace
new file mode 100644
index 0000000..91a3e10
--- /dev/null
+++ b/test/trace/getsetproperty-target-7.swf.trace
@@ -0,0 +1,6 @@
+/a/a
+42
+/a/a
+42
+/
+42
diff --git a/test/trace/getsetproperty-target-8.swf b/test/trace/getsetproperty-target-8.swf
new file mode 100644
index 0000000..edf375f
Binary files /dev/null and b/test/trace/getsetproperty-target-8.swf differ
diff --git a/test/trace/getsetproperty-target-8.swf.trace b/test/trace/getsetproperty-target-8.swf.trace
new file mode 100644
index 0000000..91a3e10
--- /dev/null
+++ b/test/trace/getsetproperty-target-8.swf.trace
@@ -0,0 +1,6 @@
+/a/a
+42
+/a/a
+42
+/
+42
diff --git a/test/trace/getsetproperty-target.as b/test/trace/getsetproperty-target.as
new file mode 100644
index 0000000..cbc2ff0
--- /dev/null
+++ b/test/trace/getsetproperty-target.as
@@ -0,0 +1,34 @@
+// makeswf -v 7 -s 200x150 -r 1 -o getsetproperty-target.swf getsetproperty-target.as
+
+createEmptyMovieClip ("a", 0);
+a.createEmptyMovieClip ("a", 0);
+
+function do_test (x) {
+ // equivalent code:
+ // trace (eval (x)._target);
+ // eval (x)._x = 42;
+ // trace (eval (x)._x);
+ asm {
+ push "x"
+ getvariable
+ dup
+ push 11
+ getproperty
+ trace
+ dup
+ push 0, 42
+ setproperty
+ push 0
+ getproperty
+ trace
+ };
+};
+
+tests = [ "/a/a", "a/../a::::a", "" ];
+
+for (i = 0; i < tests.length; i++) {
+ do_test (tests[i]);
+};
+
+
+loadMovie ("FSCommand:quit", "");
commit be4a34a44fc04b3665a0d6d0c7c7835bd1bd369d
Author: Benjamin Otte <otte at gnome.org>
Date: Sun Oct 14 14:49:37 2007 +0200
fix GetProperty and SetProperty actions to use swfdec_player_get_movie()
One more swfdec_as_context_eval() user down
diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c
index 59b6052..3055a7d 100644
--- a/libswfdec/swfdec_as_interpret.c
+++ b/libswfdec/swfdec_as_interpret.c
@@ -470,8 +470,14 @@ swfdec_action_lookup_object (SwfdecAsContext *cx, SwfdecAsObject *o, const char
gboolean dot_allowed = TRUE;
const char *start;
- if (path == end)
- return NULL;
+ if (path == end) {
+ if (o == NULL)
+ o = cx->frame->target;
+ if (SWFDEC_IS_MOVIE (o))
+ return o;
+ else
+ return NULL;
+ }
if (path[0] == '/') {
o = cx->frame->target;
@@ -550,8 +556,10 @@ swfdec_player_get_movie_from_value (SwfdecPlayer *player, SwfdecAsValue *val)
cx = SWFDEC_AS_CONTEXT (player);
s = swfdec_as_value_to_string (cx, val);
ret = swfdec_action_lookup_object (cx, NULL, s, s + strlen (s));
- if (!SWFDEC_IS_MOVIE (ret))
+ if (!SWFDEC_IS_MOVIE (ret)) {
+ SWFDEC_WARNING ("\"%s\" does not reference a movie", s);
return NULL;
+ }
return SWFDEC_MOVIE (ret);
}
@@ -607,7 +615,10 @@ swfdec_action_get_movie_by_path (SwfdecAsContext *cx, const char *path,
/* variable to use is the part after the last dot or colon */
*variable = end + 1;
/* look up object for start of path */
- movie = swfdec_action_lookup_object (cx, NULL, path, end);
+ if (path == end)
+ movie = NULL;
+ else
+ movie = swfdec_action_lookup_object (cx, NULL, path, end);
if (movie) {
*object = movie;
return TRUE;
@@ -694,58 +705,59 @@ extern struct {
static void
swfdec_action_get_property (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
{
- SwfdecAsValue *val;
- SwfdecAsObject *obj;
+ SwfdecMovie *movie;
guint id;
- id = swfdec_as_value_to_integer (cx, swfdec_as_stack_pop (cx));
- if (id > (cx->version > 4 ? 21 : 18)) {
- SWFDEC_WARNING ("trying to SetProperty %u, not allowed", id);
- goto out;
- }
- val = swfdec_as_stack_peek (cx, 1);
- swfdec_as_interpret_eval (cx, NULL, val);
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (val)) {
- obj = cx->frame->target;
- } else if (SWFDEC_AS_VALUE_IS_OBJECT (val)) {
- obj = SWFDEC_AS_VALUE_GET_OBJECT (val);
+ id = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 1));
+ if (!SWFDEC_IS_PLAYER (cx)) {
+ SWFDEC_INFO ("tried using GetProperty in a non-SwfdecPlayer context");
+ goto error;
} else {
- SWFDEC_WARNING ("not an object, can't GetProperty");
- goto out;
+ movie = swfdec_player_get_movie_from_value (SWFDEC_PLAYER (cx),
+ swfdec_as_stack_peek (cx, 2));
+ if (movie == NULL)
+ goto error;
}
- swfdec_as_object_get_variable (obj, swfdec_movieclip_props[id].name,
- swfdec_as_stack_peek (cx, 1));
+ if (id > (cx->version > 4 ? 21 : 18)) {
+ SWFDEC_WARNING ("trying to SetProperty %u, doesn't exist", id);
+ goto error;
+ }
+ swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (movie), swfdec_movieclip_props[id].name,
+ swfdec_as_stack_peek (cx, 2));
+ swfdec_as_stack_pop (cx);
return;
-out:
+error :
+ swfdec_as_stack_pop (cx);
SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_peek (cx, 1));
}
static void
swfdec_action_set_property (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
{
- SwfdecAsValue *val;
- SwfdecAsObject *obj;
+ SwfdecMovie *movie;
guint id;
id = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 2));
- if (id > (cx->version > 4 ? 21 : 18)) {
- SWFDEC_WARNING ("trying to SetProperty %u, not allowed", id);
- goto out;
- }
- val = swfdec_as_stack_peek (cx, 3);
- swfdec_as_interpret_eval (cx, NULL, val);
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (val)) {
- obj = cx->frame->target;
- } else if (SWFDEC_AS_VALUE_IS_OBJECT (val)) {
- obj = SWFDEC_AS_VALUE_GET_OBJECT (val);
+ if (!SWFDEC_IS_PLAYER (cx)) {
+ SWFDEC_INFO ("tried using GetProperty in a non-SwfdecPlayer context");
+ goto error;
} else {
- SWFDEC_WARNING ("not an object, can't get SetProperty");
- goto out;
+ movie = swfdec_player_get_movie_from_value (SWFDEC_PLAYER (cx),
+ swfdec_as_stack_peek (cx, 3));
+ if (movie == NULL)
+ goto error;
}
- swfdec_as_object_set_variable (obj, swfdec_movieclip_props[id].name,
+ if (id > (cx->version > 4 ? 21 : 18)) {
+ SWFDEC_WARNING ("trying to SetProperty %u, doesn't exist", id);
+ goto error;
+ }
+ swfdec_as_object_set_variable (SWFDEC_AS_OBJECT (movie), swfdec_movieclip_props[id].name,
swfdec_as_stack_peek (cx, 1));
-out:
+ swfdec_as_stack_pop_n (cx, 3);
+ return;
+
+error :
swfdec_as_stack_pop_n (cx, 3);
}
commit 9ee02d87b2f6837237a717b3b6232ebe7ec63c63
Author: Benjamin Otte <otte at gnome.org>
Date: Sun Oct 14 11:41:36 2007 +0200
don't crash when decoding didn't produce any output (fixes #12793)
diff --git a/libswfdec/swfdec_sound.c b/libswfdec/swfdec_sound.c
index 7ee1660..e4e9086 100644
--- a/libswfdec/swfdec_sound.c
+++ b/libswfdec/swfdec_sound.c
@@ -171,6 +171,7 @@ swfdec_sound_get_decoded (SwfdecSound *sound, SwfdecAudioFormat *format)
SwfdecBufferQueue *queue;
guint sample_bytes;
guint n_samples;
+ guint depth;
g_return_val_if_fail (SWFDEC_IS_SOUND (sound), NULL);
g_return_val_if_fail (format != NULL, NULL);
@@ -199,7 +200,12 @@ swfdec_sound_get_decoded (SwfdecSound *sound, SwfdecAudioFormat *format)
swfdec_buffer_queue_push (queue, tmp);
}
swfdec_audio_decoder_free (decoder);
- tmp = swfdec_buffer_queue_pull (queue, swfdec_buffer_queue_get_depth (queue));
+ depth = swfdec_buffer_queue_get_depth (queue);
+ if (depth == 0) {
+ SWFDEC_ERROR ("decoding didn't produce any data, bailing");
+ return NULL;
+ }
+ tmp = swfdec_buffer_queue_pull (queue, depth);
swfdec_buffer_queue_unref (queue);
SWFDEC_LOG ("after decoding, got %u samples, should get %u and skip %u",
More information about the Swfdec
mailing list