Skip to content

Commit

Permalink
Change set_pixbuf() to return NULL on failure instead of FALSE.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiers committed Apr 17, 2023
1 parent 6c085ff commit 5d8e3ce
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions contrib/gdk-pixbuf/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ GdkPixbuf* set_pixbuf(AvifAnimation * context, GError ** error)
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
"Insufficient memory to open AVIF file");
return FALSE;
return NULL;
}

rgb.pixels = gdk_pixbuf_get_pixels(output);
Expand All @@ -252,7 +252,7 @@ GdkPixbuf* set_pixbuf(AvifAnimation * context, GError ** error)
g_set_error(error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_FAILED,
"Failed to convert YUV to RGB: %s", avifResultToString(ret));
g_object_unref(output);
return FALSE;
return NULL;
}

/* transformations */
Expand Down Expand Up @@ -361,7 +361,7 @@ GdkPixbuf* set_pixbuf(AvifAnimation * context, GError ** error)
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
"Transformed AVIF has zero width or height");
g_object_unref(output);
return FALSE;
return NULL;
}

if ( width < gdk_pixbuf_get_width(output) ||
Expand Down Expand Up @@ -424,6 +424,10 @@ static gboolean avif_context_try_load(AvifAnimation * context, GError ** error)
frame.pixbuf = set_pixbuf(context, error);
frame.duration_ms = (uint64_t)(decoder->imageTiming.duration * 1000);

if (frame.pixbuf == NULL) {
return FALSE;
}

g_array_append_val(context->frames, frame);

context->prepared_func(g_array_index(context->frames, AvifAnimationFrame, 0).pixbuf,
Expand Down

0 comments on commit 5d8e3ce

Please sign in to comment.