[Swfdec] 4 commits - libswfdec/swfdec_sound_object.c libswfdec/swfdec_text_field_movie_as.c libswfdec/swfdec_text_field_movie.c test/crashfinder.c test/Makefile.am
Pekka Lampila
medar at kemper.freedesktop.org
Thu Nov 1 03:30:42 PDT 2007
libswfdec/swfdec_sound_object.c | 3
libswfdec/swfdec_text_field_movie.c | 3
libswfdec/swfdec_text_field_movie_as.c | 1
test/Makefile.am | 8 +
test/crashfinder.c | 154 +++++++++++++++++++++++++++++++++
5 files changed, 164 insertions(+), 5 deletions(-)
New commits:
commit 9d8541e233b6bb2a465bea0c7b8f8b66f37bb25a
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Thu Nov 1 12:19:21 2007 +0200
Fix an another memory leak in TextField code
diff --git a/libswfdec/swfdec_text_field_movie.c b/libswfdec/swfdec_text_field_movie.c
index 1858004..4dd9c07 100644
--- a/libswfdec/swfdec_text_field_movie.c
+++ b/libswfdec/swfdec_text_field_movie.c
@@ -51,8 +51,7 @@ static void
swfdec_text_paragraph_add_attribute (SwfdecParagraph *paragraph,
PangoAttribute *attr)
{
- paragraph->attrs =
- g_slist_prepend (paragraph->attrs, pango_attribute_copy (attr));
+ paragraph->attrs = g_slist_prepend (paragraph->attrs, attr);
}
static void
commit 5d0e30f1cc89df169e0b73cca83faa923f4b3be4
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Wed Oct 31 20:30:22 2007 +0200
Fix a memory leak in TextField code
diff --git a/libswfdec/swfdec_text_field_movie_as.c b/libswfdec/swfdec_text_field_movie_as.c
index 7d91250..673600e 100644
--- a/libswfdec/swfdec_text_field_movie_as.c
+++ b/libswfdec/swfdec_text_field_movie_as.c
@@ -1225,6 +1225,7 @@ swfdec_text_field_movie_createTextField (SwfdecAsContext *cx,
movie = swfdec_movie_new (SWFDEC_PLAYER (cx), depth, parent, parent->resource,
SWFDEC_GRAPHIC (edittext), name);
g_assert (SWFDEC_IS_TEXT_FIELD_MOVIE (movie));
+ g_object_unref (edittext);
swfdec_movie_initialize (movie);
swfdec_movie_update (movie);
commit a6df2d3a6f3d95846b9a0b516f2d1479ca208eb9
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Wed Oct 31 19:08:43 2007 +0200
Add test/crashfinder program that simply runs Flash files to find crashes
diff --git a/test/Makefile.am b/test/Makefile.am
index 8f74f60..1aca7fa 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -3,11 +3,15 @@ SUBDIRS = image sound trace various
if WITH_GTK
noinst_LTLIBRARIES = libswfedit.la
-noinst_PROGRAMS = swfdec-extract dump swfedit swfscript
+noinst_PROGRAMS = swfdec-extract dump swfedit swfscript crashfinder
else
-noinst_PROGRAMS = swfdec-extract dump
+noinst_PROGRAMS = swfdec-extract dump crashfinder
endif
+crashfinder_CFLAGS = $(GLOBAL_CFLAGS) $(SWFDEC_CFLAGS)
+crashfinder_LDFLAGS = $(SWFDEC_LIBS) $(CAIRO_LIBS)
+crashfinder_SOURCES = crashfinder.c
+
dump_CFLAGS = $(GLOBAL_CFLAGS) $(SWFDEC_CFLAGS) $(CAIRO_CFLAGS) $(PANGO_CFLAGS)
dump_LDFLAGS = $(SWFDEC_LIBS) $(CAIRO_LIBS) $(PANGO_LIBS)
diff --git a/test/crashfinder.c b/test/crashfinder.c
new file mode 100644
index 0000000..418c9d0
--- /dev/null
+++ b/test/crashfinder.c
@@ -0,0 +1,154 @@
+/* Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ * 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <libswfdec/swfdec.h>
+
+int
+main (int argc, char **argv)
+{
+ GOptionContext *context;
+ GError *err;
+ SwfdecPlayer *player;
+ SwfdecLoader *loader;
+ guint i;
+ cairo_surface_t *surface;
+ cairo_t *cr;
+ gboolean aborts;
+ glong play_per_file = 30;
+ glong max_per_file = 60;
+ glong max_per_advance = 10;
+ GTimer *timer;
+ char **filenames = NULL;
+ const GOptionEntry entries[] = {
+ {
+ "play-time", 'p', 0, G_OPTION_ARG_INT, &play_per_file,
+ "How many seconds will be played from each file (default 30)", NULL
+ },
+ {
+ "max-per-file", '\0', 0, G_OPTION_ARG_INT, &max_per_file,
+ "Maximum runtime in seconds allowed for each file (default 60)", NULL
+ },
+ {
+ "max-per-advance", '\0', 0, G_OPTION_ARG_INT, &max_per_advance,
+ "Maximum runtime in seconds allowed for each advance (default 10)", NULL
+ },
+ {
+ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames,
+ NULL, "<INPUT FILE> <OUTPUT FILE>"
+ },
+ {
+ NULL
+ }
+ };
+
+ // init
+ swfdec_init ();
+
+ // read command line params
+ context = g_option_context_new ("Run a Flash file trying to crash Swfdec");
+ g_option_context_add_main_entries (context, entries, NULL);
+
+ if (g_option_context_parse (context, &argc, &argv, &err) == FALSE) {
+ g_printerr ("Couldn't parse command-line options: %s\n", err->message);
+ g_error_free (err);
+ return 1;
+ }
+
+ if (filenames == NULL || g_strv_length (filenames) < 1) {
+ g_printerr ("At least one input filename is required\n");
+ return 1;
+ }
+
+ // make them milliseconds
+ play_per_file *= 1000;
+ max_per_file *= 1000;
+ max_per_advance *= 1000;
+
+ // create surface
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
+ cr = cairo_create (surface);
+
+ aborts = FALSE;
+ for (i = 0; i < g_strv_length (filenames); i++)
+ {
+ glong played, advance, elapsed;
+
+ g_print ("Running: %s\n", filenames[i]);
+
+ // start timer
+ timer = g_timer_new ();
+
+ // create player
+ loader = swfdec_file_loader_new (filenames[i]);
+ player = swfdec_player_new (NULL);
+
+ if (loader->error) {
+ g_printerr ("Error loading %s: %s\n", filenames[i], loader->error);
+ g_object_unref (loader);
+ continue;
+ }
+
+ swfdec_player_set_loader (player, loader);
+
+ // loop until we have played what we wanted, or timelimit is hit
+ played = 0;
+ elapsed = 0;
+ while (played < play_per_file &&
+ !swfdec_as_context_is_aborted (SWFDEC_AS_CONTEXT (player)))
+ {
+ elapsed = (glong)(g_timer_elapsed (timer, NULL) * 1000);
+ if (elapsed >= max_per_file)
+ break;
+ swfdec_player_set_maximum_runtime (player,
+ MIN (max_per_advance, max_per_file - elapsed));
+
+ advance = swfdec_player_get_next_event (player);
+ swfdec_player_advance (player, advance);
+
+ swfdec_player_render (player, cr, 0, 0, 0, 0);
+
+ played += advance;
+ }
+
+ if (elapsed >= max_per_file ||
+ swfdec_as_context_is_aborted (SWFDEC_AS_CONTEXT (player))) {
+ g_print ("Aborted: %s\n", filenames[i]);
+ aborts = TRUE;
+ } else {
+ g_print ("Finished: %s\n", filenames[i]);
+ }
+
+ // clean up
+ g_object_unref (player);
+ g_timer_destroy (timer);
+ }
+
+ cairo_destroy (cr);
+ cairo_surface_destroy (surface);
+
+ if (aborts) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
commit e62589ee79f26dead719bfb2ab6f45f58f822693
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Wed Oct 31 15:10:40 2007 +0200
Fix an assert in swfdec_sound_object_mark
diff --git a/libswfdec/swfdec_sound_object.c b/libswfdec/swfdec_sound_object.c
index 85e870e..98d00a0 100644
--- a/libswfdec/swfdec_sound_object.c
+++ b/libswfdec/swfdec_sound_object.c
@@ -43,7 +43,8 @@ swfdec_sound_object_mark (SwfdecAsObject *object)
{
SwfdecSoundObject *sound = SWFDEC_SOUND_OBJECT (object);
- swfdec_as_object_mark (SWFDEC_AS_OBJECT (sound->target));
+ if (sound->target != NULL)
+ swfdec_as_object_mark (SWFDEC_AS_OBJECT (sound->target));
SWFDEC_AS_OBJECT_CLASS (swfdec_sound_object_parent_class)->mark (object);
}
More information about the Swfdec
mailing list