richedit: Prevent using uninitialized nAvailWidth in initialization.

Dylan Smith dylan.ah.smith at gmail.com
Fri Jul 31 10:37:13 CDT 2009


I found this using Valgrind that nAvailWidth gets used uninitialized
during initialization.

ME_MakeEditor initializes nAvailWidth after calling
ME_MakeFirstParagraph that uses the value though a call to
ME_InitContext. This doesn't doesn't actually cause a bug though,
because it only affects the value of a field in the ME_Context for
ME_MakeFirstParagraph that isn't used on initialization. I decided to
fix it anyways to avoid suprises as the code gets modified.
---
 dlls/riched20/editor.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
-------------- next part --------------
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 1e18c10..3008bf1 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -2600,6 +2600,7 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
                      ES_AUTOHSCROLL|ES_DISABLENOSCROLL);
   ed->pBuffer = ME_MakeText();
   ed->nZoomNumerator = ed->nZoomDenominator = 0;
+  ed->nAvailWidth = 0; /* wrap to client area */
   ME_MakeFirstParagraph(ed);
   /* The four cursors are for:
    * 0 - The position where the caret is shown
@@ -2632,7 +2633,6 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
   ed->nParagraphs = 1;
   ed->nLastSelStart = ed->nLastSelEnd = 0;
   ed->pLastSelStartPara = ed->pLastSelEndPara = ME_FindItemFwd(ed->pBuffer->pFirst, diParagraph);
-  ed->nAvailWidth = 0; /* wrap to client area */
   ed->bHideSelection = FALSE;
   ed->pfnWordBreak = NULL;
   ed->lpOleCallback = NULL;


More information about the wine-patches mailing list