From: Jason Rumney Date: Thu, 4 Dec 2008 15:21:53 +0000 (+0000) Subject: (w32font_draw): Initialize orig_clip before getting it, and delete it X-Git-Tag: emacs-pretest-23.0.90~1279 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f70eb806e6098baa63c843d56372de9ea30e42f2;p=emacs.git (w32font_draw): Initialize orig_clip before getting it, and delete it when finished. --- diff --git a/src/w32font.c b/src/w32font.c index c9494b4f29c..9609605306f 100644 --- a/src/w32font.c +++ b/src/w32font.c @@ -530,18 +530,23 @@ w32font_draw (s, from, to, x, y, with_background) int from, to, x, y, with_background; { UINT options; - HRGN orig_clip; + HRGN orig_clip = NULL; struct w32font_info *w32font = (struct w32font_info *) s->font; options = w32font->glyph_idx; - /* Save clip region for later restoration. */ - GetClipRgn(s->hdc, orig_clip); - if (s->num_clips > 0) { HRGN new_clip = CreateRectRgnIndirect (s->clip); + /* Save clip region for later restoration. */ + orig_clip = CreateRectRgn (0, 0, 0, 0); + if (!GetClipRgn(s->hdc, orig_clip)) + { + DeleteObject (orig_clip); + orig_clip = NULL; + } + if (s->num_clips > 1) { HRGN clip2 = CreateRectRgnIndirect (s->clip + 1); @@ -585,9 +590,10 @@ w32font_draw (s, from, to, x, y, with_background) /* Restore clip region. */ if (s->num_clips > 0) - { - SelectClipRgn (s->hdc, orig_clip); - } + SelectClipRgn (s->hdc, orig_clip); + + if (orig_clip) + DeleteObject (orig_clip); } /* w32 implementation of free_entity for font backend.