richedit: Prevent uninitialized value from being used.

Dylan Smith dylan.ah.smith at gmail.com
Mon Jan 25 00:27:24 CST 2010


NULL may be returned by ITextHost::TxGetDC.

Caught by valgrind.
---
 dlls/riched20/run.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20100125/58abca2d/attachment.htm>
-------------- next part --------------
diff --git a/dlls/riched20/run.c b/dlls/riched20/run.c
index 90ea831..cd282ec 100644
--- a/dlls/riched20/run.c
+++ b/dlls/riched20/run.c
@@ -550,9 +550,14 @@ int ME_CharFromPointCursor(ME_TextEditor *editor, int cx, ME_Run *run)
 static void ME_GetTextExtent(ME_Context *c, LPCWSTR szText, int nChars, ME_Style *s, SIZE *size)
 {
   HGDIOBJ hOldFont;
-  hOldFont = ME_SelectStyleFont(c, s);
-  GetTextExtentPoint32W(c->hDC, szText, nChars, size);
-  ME_UnselectStyleFont(c, s, hOldFont);
+  if (c->hDC) {
+    hOldFont = ME_SelectStyleFont(c, s);
+    GetTextExtentPoint32W(c->hDC, szText, nChars, size);
+    ME_UnselectStyleFont(c, s, hOldFont);
+  } else {
+    size->cx = 0;
+    size->cy = 0;
+  }
 }
 
 /******************************************************************************


More information about the wine-patches mailing list