[cairo-commit] 2 commits - src/cairo-quartz-surface.c
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jun 30 16:03:18 UTC 2022
src/cairo-quartz-surface.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
New commits:
commit d64f9699eb86b9c55cbf5c729178635e7fc2c75d
Merge: c68ff21e4 cccc81ccb
Author: Jeff Muizelaar <jrmuizel at gmail.com>
Date: Thu Jun 30 16:03:16 2022 +0000
Merge branch 'quartz-memcpy' into 'master'
quartz: Avoid reading beyond the end of image surfaces.
See merge request cairo/cairo!337
commit cccc81ccba99600483621e02ae9438a4a5a3d024
Author: Jeff Muizelaar <jrmuizel at gmail.com>
Date: Wed Jun 29 11:41:47 2022 -0400
quartz: Avoid reading beyond the end of image surfaces.
The last row of data may have less than stride bytes so make sure we
only copy what we need.
diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c
index 97ddf2c28..6676dc960 100644
--- a/src/cairo-quartz-surface.c
+++ b/src/cairo-quartz-surface.c
@@ -772,8 +772,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,
More information about the cairo-commit
mailing list