cairo_win32_surface_get_dc: Return NULL for error surfaces

Surfaces from _cairo_surface_create_in_error() have no backend. This
commit fixes a NULL pointer dereference in cairo_win32_surface_get_dc().

Fixes: https://gitlab.freedesktop.org/cairo/cairo/-/issues/405
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2021-01-13 16:26:18 +01:00
parent 974791b4ee
commit 0134ac5a3d

View file

@ -155,6 +155,9 @@ _cairo_win32_surface_get_extents (void *abstract_surface,
HDC
cairo_win32_surface_get_dc (cairo_surface_t *surface)
{
if (surface->backend == NULL)
return NULL;
if (surface->backend->type == CAIRO_SURFACE_TYPE_WIN32)
return to_win32_surface(surface)->dc;