From 8aba5b802946530ef481f1461f9894529498cd8a Mon Sep 17 00:00:00 2001 From: Vladimir Vukicevic Date: Tue, 25 Mar 2008 11:53:52 -0700 Subject: [win32] Prevent crash in create_similar if win32_surface_create fails --- src/cairo-win32-surface.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/cairo-win32-surface.c b/src/cairo-win32-surface.c index 5719c6de4..bfe71b4f3 100644 --- a/src/cairo-win32-surface.c +++ b/src/cairo-win32-surface.c @@ -410,9 +410,15 @@ _cairo_win32_surface_create_similar_internal (void *abstract_src, saved_dc_bitmap = SelectObject (ddb_dc, ddb); new_surf = (cairo_win32_surface_t*) cairo_win32_surface_create (ddb_dc); - new_surf->bitmap = ddb; - new_surf->saved_dc_bitmap = saved_dc_bitmap; - new_surf->is_dib = FALSE; + if (new_surf->base.status == CAIRO_STATUS_SUCCESS) { + new_surf->bitmap = ddb; + new_surf->saved_dc_bitmap = saved_dc_bitmap; + new_surf->is_dib = FALSE; + } else { + SelectObject (ddb_dc, saved_dc_bitmap); + DeleteDC (ddb_dc); + DeleteObject (ddb); + } } return (cairo_surface_t*) new_surf; -- cgit v1.2.3