'Fix' a NULL pointer 'dereference' in cairo-pdf-surface

The expression &image_surface->base basically just casts the
cairo_image_surface_t* to cairo_surface_t*. However, technically it is a
NULL pointer dereference and UndefinedBehaviorSanitizer flags it as
such:

runtime error: member access within null pointer of type 'cairo_image_surface_t' (aka 'struct _cairo_image_surface')

This commit fixes this by adding a NULL check.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2021-01-17 20:59:58 +01:00
parent d72ff7c18a
commit 4e2e876be1

View file

@ -943,7 +943,8 @@ _cairo_pdf_surface_clear (cairo_pdf_surface_t *surface)
_cairo_array_truncate (&surface->knockout_group, 0);
_cairo_array_truncate (&surface->page_annots, 0);
cairo_surface_destroy (&surface->thumbnail_image->base);
if (surface->thumbnail_image)
cairo_surface_destroy (&surface->thumbnail_image->base);
surface->thumbnail_image = NULL;
}