From: Matthew Fernandez Date: Thu, 31 Mar 2022 03:36:40 +0000 (-0700) Subject: webp_really_loadimage: correct type for 'data_size' X-Git-Tag: 4.0.0~146^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=03a5c3621e3185e4ca116805317a98cdc8595443;p=graphviz webp_really_loadimage: correct type for 'data_size' Squashes a -Wconversion warning. --- 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;