]> granicus.if.org Git - graphviz/commitdiff
GDK plugin gdk_format: squash -Wsign-conversion warnings
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 3 Apr 2022 19:56:15 +0000 (12:56 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 9 Apr 2022 01:03:38 +0000 (18:03 -0700)
plugin/gdk/gvdevice_gdk.c

index 15ebb0568e4db044cf089daa4b80942d574bd312..0e278d34a18ba65db9ed1d1d71365eed938808fd 100644 (file)
@@ -9,9 +9,11 @@
  *************************************************************************/
 
 #include "config.h"
+#include <assert.h>
 #include <cgraph/unreachable.h>
 #include <gvc/gvplugin_device.h>
 #include <gvc/gvio.h>
+#include <limits.h>
 #ifdef HAVE_PANGOCAIRO
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
@@ -87,14 +89,17 @@ static void gdk_format(GVJ_t * job)
 
     argb2rgba(job->width, job->height, job->imagedata);
 
+    assert(job->width <= (unsigned)INT_MAX / 4 && "width out of range");
+    assert(job->height <= (unsigned)INT_MAX && "height out of range");
+
     pixbuf = gdk_pixbuf_new_from_data(
                 (unsigned char*)(job->imagedata), // data
                 GDK_COLORSPACE_RGB,     // colorspace
                 TRUE,                   // has_alpha
                 8,                      // bits_per_sample
-                job->width,             // width
-                job->height,            // height
-                4 * job->width,         // rowstride
+                (int)job->width,        // width
+                (int)job->height,       // height
+                4 * (int)job->width,    // rowstride
                 NULL,                   // destroy_fn
                 NULL                    // destroy_fn_data
                );