From: Michael Orlitzky Date: Mon, 7 Aug 2023 00:49:59 +0000 (-0400) Subject: io-svg.c: defend against things that shouldn't happen X-Git-Tag: 0.0.1~15 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=de518a40ee4f9108b3d27bbea894f3596e2107c5;p=libsvgtiny-pixbuf.git io-svg.c: defend against things that shouldn't happen --- 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; }