summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Vukicevic <vladimir@pobox.com>2008-03-25 11:53:52 -0700
committerVladimir Vukicevic <vladimir@h-232.office.mozilla.org>2008-03-25 11:53:52 -0700
commit8aba5b802946530ef481f1461f9894529498cd8a (patch)
tree3b57c3d7be93e475cbab5b4d8f43fb548ebe1f88
parent49a140b04bda85c03f824dcf565f1fcdd70b8965 (diff)
[win32] Prevent crash in create_similar if win32_surface_create fails
-rw-r--r--src/cairo-win32-surface.c12
1 files 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;