[librsvg] Fix crash when rendering style only file.
- From: Hiroyuki Ikezoe <hiikezoe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] Fix crash when rendering style only file.
- Date: Thu, 3 Jun 2010 11:16:25 +0000 (UTC)
commit a55aa23ca95c749821c44c3d705adad0258305d9
Author: Hiroyuki Ikezoe <hiikezoe gnome org>
Date: Wed Jun 2 20:13:19 2010 +0900
Fix crash when rendering style only file.
Fix for bug #620238.
rsvg-base.c | 2 +-
tests/Makefile.am | 1 +
tests/crash.c | 52 ++++++++++++++++++++++++++++++++++++
tests/fixtures/crash/bug620238.svg | 1 +
4 files changed, 55 insertions(+), 1 deletions(-)
---
diff --git a/rsvg-base.c b/rsvg-base.c
index c4b2027..71ed7a9 100644
--- a/rsvg-base.c
+++ b/rsvg-base.c
@@ -690,7 +690,7 @@ rsvg_end_element (void *data, const xmlChar * name)
&& !strcmp ((const char *) name, ctx->priv->currentnode->type->str))
rsvg_pop_def_group (ctx);
- if (!strcmp ((const char *)name, "style"))
+ if (ctx->priv->treebase && !strcmp ((const char *)name, "style"))
_rsvg_node_svg_apply_atts ((RsvgNodeSvg *)ctx->priv->treebase, ctx);
}
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 87f388b..9ce473f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -2,6 +2,7 @@ SUBDIRS=pdiff .
TESTS = \
rsvg-test \
+ crash \
dimensions \
styles
diff --git a/tests/crash.c b/tests/crash.c
new file mode 100644
index 0000000..aa5c1a9
--- /dev/null
+++ b/tests/crash.c
@@ -0,0 +1,52 @@
+/* vim: set ts=4 nowrap ai expandtab sw=4: */
+
+#include <glib.h>
+#include "rsvg.h"
+#include "test-utils.h"
+
+typedef struct _FixtureData
+{
+ const gchar *test_name;
+ const gchar *file_path;
+} FixtureData;
+
+static void
+test_crash (FixtureData *fixture)
+{
+ RsvgHandle *handle;
+ gchar *target_file;
+ GError *error = NULL;
+
+ target_file = g_build_filename (test_utils_get_test_data_path (),
+ fixture->file_path, NULL);
+ handle = rsvg_handle_new_from_file (target_file, &error);
+ g_free (target_file);
+ g_assert_no_error (error);
+
+ g_object_unref (handle);
+}
+
+static FixtureData fixtures[] =
+{
+ {"/crash/only style information", "crash/bug620238.svg"}
+};
+
+static const gint n_fixtures = G_N_ELEMENTS (fixtures);
+
+int
+main (int argc, char *argv[])
+{
+ gint i;
+ int result;
+
+ rsvg_init ();
+ g_test_init (&argc, &argv, NULL);
+
+ for (i = 0; i < n_fixtures; i++)
+ g_test_add_data_func (fixtures[i].test_name, &fixtures[i], (void*)test_crash);
+
+ result = g_test_run ();
+ rsvg_term ();
+
+ return result;
+}
diff --git a/tests/fixtures/crash/bug620238.svg b/tests/fixtures/crash/bug620238.svg
new file mode 100644
index 0000000..ac9c811
--- /dev/null
+++ b/tests/fixtures/crash/bug620238.svg
@@ -0,0 +1 @@
+<style type="text/css"> </style>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]