Fixed conversion range checks and cast for use with cairo
@@ -584,10 +584,18 @@ BOOL wlf_copy_image(const void* src, size_t srcStride, size_t srcWidth, size_t s
const double sx = (double)dstWidth / (double)srcWidth;
const double sy = (double)dstHeight / (double)srcHeight;
cairo_t* cairo_context;
- cairo_surface_t* csrc = cairo_image_surface_create_for_data(src, CAIRO_FORMAT_ARGB32, srcWidth,
- srcHeight, srcStride);
- cairo_surface_t* cdst = cairo_image_surface_create_for_data(dst, CAIRO_FORMAT_ARGB32, dstWidth,
- dstHeight, dstStride);
+ cairo_surface_t *csrc, *cdst;
+
+ if ((srcWidth > INT_MAX) || (srcHeight > INT_MAX) || (srcStride > INT_MAX))
+ return FALSE;
+
+ if ((dstWidth > INT_MAX) || (dstHeight > INT_MAX) || (dstStride > INT_MAX))
+ return FALSE;
+
+ csrc = cairo_image_surface_create_for_data((void*)src, CAIRO_FORMAT_ARGB32, (int)srcWidth,
+ (int)srcHeight, (int)srcStride);
+ cdst = cairo_image_surface_create_for_data(dst, CAIRO_FORMAT_ARGB32, (int)dstWidth,
+ (int)dstHeight, (int)dstStride);
if (!csrc || !cdst)
goto fail;
