From: Matthew Fernandez Date: Thu, 31 Mar 2022 03:30:34 +0000 (-0700) Subject: webp_format: squash -Wsign-conversion warnings X-Git-Tag: 4.0.0~146^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e36e62d51a412a78a69f82e101018ab083bd5e40;p=graphviz webp_format: squash -Wsign-conversion warnings --- diff --git a/plugin/webp/gvdevice_webp.c b/plugin/webp/gvdevice_webp.c index 4331a8229..6bded0c76 100644 --- a/plugin/webp/gvdevice_webp.c +++ b/plugin/webp/gvdevice_webp.c @@ -55,9 +55,17 @@ static void webp_format(GVJ_t * job) goto Error; } - picture.width = job->width; - picture.height = job->height; - stride = 4 * job->width; + // if either dimension exceeds the WebP API, map this to one of its errors + if ((unsigned)INT_MAX / 4 < job->width || job->height > (unsigned)INT_MAX) { + int error = VP8_ENC_ERROR_BAD_DIMENSION; + fprintf(stderr, "Error! Cannot encode picture as WebP\n"); + fprintf(stderr, "Error code: %d (%s)\n", error, kErrorMessages[error]); + goto Error; + } + + picture.width = (int)job->width; + picture.height = (int)job->height; + stride = 4 * (int)job->width; picture.writer = writer; picture.custom_ptr = job;