]> gitweb.michael.orlitzky.com - libsvgtiny-pixbuf.git/commitdiff
io-svg.c: defend against things that shouldn't happen
authorMichael Orlitzky <michael@orlitzky.com>
Mon, 7 Aug 2023 00:49:59 +0000 (20:49 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Mon, 7 Aug 2023 00:49:59 +0000 (20:49 -0400)
io-svg.c

index b1cb332f1aca74a059fea117f42eb91dcd126867..535b1f7dc928b96b108dc445d2ba06683fb4d544 100644 (file)
--- a/io-svg.c
+++ b/io-svg.c
@@ -504,9 +504,14 @@ static gchar* process_gtk_symbolic_svg_xinclude(const gchar* buffer,
 static gboolean gdk_pixbuf_stop_load(gpointer data, GError **error) {
   SvgTinyContext* context = (SvgTinyContext*)data;
   GdkPixbuf* pixbuf = NULL;
-  gboolean result = TRUE;
   GError* sub_error = NULL;
 
+  g_assert(context != NULL);
+  if (context->svg_data == NULL || context->svg_data_size == 0) {
+    /* Is it possible to begin/stop with no increments in between?
+     * I sure don't know. Let's play it safe. */
+    return FALSE;
+  }
 
   /* If we're inside of gtk-encode-symbolic-svg right now, we need to
      process the insane librsvg-specific XInclude directive it hands
@@ -533,12 +538,12 @@ static gboolean gdk_pixbuf_stop_load(gpointer data, GError **error) {
   }
   else {
     g_propagate_error(error, sub_error);
-    result = FALSE;
+    return FALSE;
   }
   g_free(context->svg_data);
   g_free(context);
 
-  return result;
+  return TRUE;
 }