mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 23:58:25 +02:00
[image] Check create_for_data() to ensure a valid minimum stride.
Double check that the user is not being silly by passing in a stride that is too small for the width. evince/poppler is one such example...
This commit is contained in:
parent
88f628b397
commit
9481d999df
1 changed files with 12 additions and 0 deletions
|
|
@ -484,6 +484,7 @@ cairo_image_surface_create_for_data (unsigned char *data,
|
|||
int stride)
|
||||
{
|
||||
pixman_format_code_t pixman_format;
|
||||
int minstride;
|
||||
|
||||
if (! CAIRO_FORMAT_VALID (format))
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
|
||||
|
|
@ -491,6 +492,17 @@ cairo_image_surface_create_for_data (unsigned char *data,
|
|||
if ((stride & (CAIRO_STRIDE_ALIGNMENT-1)) != 0)
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_STRIDE));
|
||||
|
||||
minstride = cairo_format_stride_for_width (format, width);
|
||||
if (stride < 0) {
|
||||
if (stride > -minstride) {
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_STRIDE));
|
||||
}
|
||||
} else {
|
||||
if (stride < minstride) {
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_STRIDE));
|
||||
}
|
||||
}
|
||||
|
||||
pixman_format = _cairo_format_to_pixman_format_code (format);
|
||||
|
||||
return _cairo_image_surface_create_with_pixman_format (data, pixman_format,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue