richedit: Prevent an unsigned integer underflow.

Dylan Smith dylan.ah.smith at gmail.com
Sun Jan 11 01:59:38 CST 2009


The calculation to see if the scrollbar was visible was subtracting from
an unsigned integer that is initially 0, so this would cause the value
to wrap around.  This calculation should be the same as the calculating
to find out the scrollbar will be visible, so I changed it accordingly.

The bug can be seen by opening winhlp32 with a small help file specified
on the command line.  The vertical scrollbar would initially be visible,
even though there is less than a page of text.
---
 dlls/riched20/paint.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
-------------- next part --------------
diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c
index f0acf4a..b6430e4 100644
--- a/dlls/riched20/paint.c
+++ b/dlls/riched20/paint.c
@@ -1127,7 +1127,7 @@ int ME_GetYScrollPos(ME_TextEditor *editor)
 
 BOOL ME_GetYScrollVisible(ME_TextEditor *editor)
 { /* Returns true if the scrollbar is visible */
-  return (editor->vert_si.nMax - editor->vert_si.nMin >= max(editor->vert_si.nPage - 1, 0));
+  return (editor->vert_si.nMax - editor->vert_si.nMin > editor->vert_si.nPage);
 }
 
 void ME_EnsureVisible(ME_TextEditor *editor, ME_DisplayItem *pRun)


More information about the wine-patches mailing list