From de518a40ee4f9108b3d27bbea894f3596e2107c5 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sun, 6 Aug 2023 20:49:59 -0400 Subject: [PATCH] io-svg.c: defend against things that shouldn't happen --- io-svg.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/io-svg.c b/io-svg.c index b1cb332..535b1f7 100644 --- 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; } -- 2.43.2