From 03a5c3621e3185e4ca116805317a98cdc8595443 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Wed, 30 Mar 2022 20:36:40 -0700 Subject: [PATCH] webp_really_loadimage: correct type for 'data_size' Squashes a -Wconversion warning. --- plugin/webp/gvloadimage_webp.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/plugin/webp/gvloadimage_webp.c b/plugin/webp/gvloadimage_webp.c index 58a29bd30..207f0a9b4 100644 --- a/plugin/webp/gvloadimage_webp.c +++ b/plugin/webp/gvloadimage_webp.c @@ -55,7 +55,6 @@ static cairo_surface_t* webp_really_loadimage(const char *in_file, FILE* const i VP8StatusCode status = VP8_STATUS_OK; cairo_surface_t *surface = NULL; /* source surface */ int ok; - uint32_t data_size = 0; void* data = NULL; if (!WebPInitDecoderConfig(&config)) { @@ -64,12 +63,17 @@ static cairo_surface_t* webp_really_loadimage(const char *in_file, FILE* const i } fseek(in, 0, SEEK_END); - data_size = ftell(in); + long size = ftell(in); + if (size < 0) { + fprintf(stderr, "Error: WebP could not determine %s size\n", in_file); + return NULL; + } + size_t data_size = (size_t)size; fseek(in, 0, SEEK_SET); data = malloc(data_size); ok = (fread(data, data_size, 1, in) == 1); if (!ok) { - fprintf(stderr, "Error: WebP could not read %d bytes of data from %s\n", + fprintf(stderr, "Error: WebP could not read %zu bytes of data from %s\n", data_size, in_file); free(data); return NULL; -- 2.40.0