rsvgoverlay: Do not segfault on unexistent files
authorThiago Santos <thiago.sousa.santos@collabora.co.uk>
Tue, 25 Jan 2011 02:32:30 +0000 (23:32 -0300)
committerThiago Santos <thiago.sousa.santos@collabora.co.uk>
Tue, 25 Jan 2011 02:51:53 +0000 (23:51 -0300)
When passing an unexistent file to rsvgoverlay it would
crash because the svg loading would fail without setting
an error.

This patch makes it check if the handle was actually created
and logs an error in case it didn't. Maybe it should post an
error to the bus, but the previous error handling didn't, so
I just followed the same logic.

ext/rsvg/gstrsvgoverlay.c

index 60fd167..2a5bdc1 100644 (file)
@@ -126,10 +126,14 @@ gst_rsvg_overlay_set_svg_data (GstRsvgOverlay * overlay, const gchar * data,
       else
         overlay->handle =
             rsvg_handle_new_from_data ((guint8 *) data, size, &error);
-      if (error) {
-        GST_ERROR_OBJECT (overlay, "Cannot read SVG data: %s\n%s",
-            error->message, data);
-        g_error_free (error);
+      if (error || overlay->handle == NULL) {
+        if (error) {
+          GST_ERROR_OBJECT (overlay, "Cannot read SVG data: %s\n%s",
+              error->message, data);
+          g_error_free (error);
+        } else {
+          GST_ERROR_OBJECT (overlay, "Cannot read SVG data: %s", data);
+        }
       } else {
         /* Get SVG dimension. */
         RsvgDimensionData svg_dimension;