Bug 1778158 - quartz: Avoid reading beyond the end of image surfaces. r=jfkthame

The last row of data may have less than stride bytes so make sure we
only copy what we need.

This corresponds to cairo:cccc81ccba99600483621e02ae9438a4a5a3d024

Differential Revision: https://phabricator.services.mozilla.com/D151053
This commit is contained in:
Jeff Muizelaar 2022-07-06 12:25:10 +00:00
Родитель 42807f13f3
Коммит d9dcf5b2b6
1 изменённых файлов: 5 добавлений и 1 удалений

Просмотреть файл

@ -873,8 +873,12 @@ _cairo_surface_to_cgimage (cairo_surface_t *source,
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
// The last row of data may have less than stride bytes so make sure we
// only copy the minimum amount required from that row.
memcpy (image_data, image_surface->data,
image_surface->height * image_surface->stride);
(image_surface->height - 1) * image_surface->stride +
cairo_format_stride_for_width (image_surface->format,
image_surface->width));
*image_out = CairoQuartzCreateCGImage (image_surface->format,
image_surface->width,
image_surface->height,