diff --git a/io-webp.c b/io-webp.c index 630e2de..ae4d3f9 100644 --- a/io-webp.c +++ b/io-webp.c @@ -15,10 +15,10 @@ static gpointer begin_load (GdkPixbufModuleSizeFunc size_func, - GdkPixbufModulePreparedFunc prepare_func, - GdkPixbufModuleUpdatedFunc update_func, - gpointer user_data, - GError **error) + GdkPixbufModulePreparedFunc prepare_func, + GdkPixbufModuleUpdatedFunc update_func, + gpointer user_data, + GError **error) { WebPContext *context = g_new0 (WebPContext, 1); context->size_func = size_func; @@ -90,13 +90,22 @@ load_increment (gpointer data, const guchar *buf, guint size, GError **error) context->deccfg.output.colorspace = features.has_alpha ? MODE_RGBA : MODE_RGB; - guint len = 0; + guint len = 0; + context->deccfg.output.is_external_memory = TRUE; context->deccfg.output.u.RGBA.rgba = gdk_pixbuf_get_pixels_with_length (context->pixbuf, &len); context->deccfg.output.u.RGBA.stride = gdk_pixbuf_get_rowstride (context->pixbuf); context->deccfg.output.u.RGBA.size = (size_t) len; context->idec = WebPIDecode (NULL, 0, &context->deccfg); + if (context->idec == NULL) + { + g_set_error (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_CORRUPT_IMAGE, + "Could not allocate WebPIDecode"); + g_clear_object (&context->pixbuf); + return FALSE; + } + context->prepare_func (context->pixbuf, NULL, context->user_data); } @@ -169,8 +178,6 @@ stop_load (gpointer data, GError **error) ret = TRUE; } - WebPFreeDecBuffer (&context->deccfg.output); - g_clear_pointer (&context->idec, WebPIDelete); g_clear_object (&context->pixbuf); g_free (context);