create_bits (pixman_format_code_t format,
int width,
int height,
- int * rowstride_bytes)
+ int * rowstride_bytes)
{
int stride;
- int buf_size;
+ size_t buf_size;
int bpp;
/* what follows is a long-winded way, avoiding any possibility of integer
*/
bpp = PIXMAN_FORMAT_BPP (format);
- if (pixman_multiply_overflows_int (width, bpp))
+ if (_pixman_multiply_overflows_int (width, bpp))
return NULL;
stride = width * bpp;
- if (pixman_addition_overflows_int (stride, 0x1f))
+ if (_pixman_addition_overflows_int (stride, 0x1f))
return NULL;
stride += 0x1f;
stride *= sizeof (uint32_t);
- if (pixman_multiply_overflows_int (height, stride))
+ if (_pixman_multiply_overflows_size (height, stride))
return NULL;
buf_size = height * stride;
pixman_malloc_abc (unsigned int a, unsigned int b, unsigned int c);
pixman_bool_t
-pixman_multiply_overflows_int (unsigned int a, unsigned int b);
+_pixman_multiply_overflows_size (size_t a, size_t b);
pixman_bool_t
-pixman_addition_overflows_int (unsigned int a, unsigned int b);
+_pixman_multiply_overflows_int (unsigned int a, unsigned int b);
+
+pixman_bool_t
+_pixman_addition_overflows_int (unsigned int a, unsigned int b);
/* Compositing utilities */
void
#include "pixman-private.h"
pixman_bool_t
-pixman_multiply_overflows_int (unsigned int a,
- unsigned int b)
+_pixman_multiply_overflows_size (size_t a, size_t b)
+{
+ return a >= SIZE_MAX / b;
+}
+
+pixman_bool_t
+_pixman_multiply_overflows_int (unsigned int a, unsigned int b)
{
return a >= INT32_MAX / b;
}
pixman_bool_t
-pixman_addition_overflows_int (unsigned int a,
- unsigned int b)
+_pixman_addition_overflows_int (unsigned int a, unsigned int b)
{
return a > INT32_MAX - b;
}