diff options
author | Vladimir Vukicevic <vladimir@pobox.com> | 2007-06-19 13:15:21 -0700 |
---|---|---|
committer | Vladimir Vukicevic <vladimir@feisty.(none)> | 2007-06-29 09:46:08 -0700 |
commit | 5c7d2d14d78e4dfb1ef6d2c40f0910f177e07360 (patch) | |
tree | bb1abcb2f1144059d4444d8db343014e07791593 /src/cairo-beos-surface.cpp | |
parent | fc34073464c487405b6e2e0a5fa269a1ae15a02a (diff) |
[fix] Avoid int overflow when allocating large buffers
This patch introduces three macros: _cairo_malloc_ab,
_cairo_malloc_abc, _cairo_malloc_ab_plus_c and replaces various calls
to malloc(a*b), malloc(a*b*c), and malloc(a*b+c) with them. The macros
return NULL if int overflow would occur during the allocation. See
CODING_STYLE for more information.
Diffstat (limited to 'src/cairo-beos-surface.cpp')
-rw-r--r-- | src/cairo-beos-surface.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/cairo-beos-surface.cpp b/src/cairo-beos-surface.cpp index abf094a1..193fa43f 100644 --- a/src/cairo-beos-surface.cpp +++ b/src/cairo-beos-surface.cpp @@ -259,7 +259,7 @@ premultiply_rgba (unsigned char* data, int height, int stride) { - unsigned char* retdata = reinterpret_cast<unsigned char*>(malloc(stride * height)); + unsigned char* retdata = reinterpret_cast<unsigned char*>(_cairo_malloc_ab(height, stride)); if (!retdata) return NULL; @@ -322,7 +322,7 @@ _cairo_beos_bitmap_to_surface (BBitmap* bitmap) bitmap->BytesPerRow()); } else { premultiplied = reinterpret_cast<unsigned char*>( - malloc(bitmap->BytesPerRow() * height)); + _cairo_malloc_ab(bitmap->BytesPerRow(), height)); if (premultiplied) memcpy(premultiplied, bits, bitmap->BytesPerRow() * height); } |