https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a4bd2449adc9d129bf6ccb3dcfc4b9c06149f708

commit a4bd2449adc9d129bf6ccb3dcfc4b9c06149f708
Author:     Katayama Hirofumi MZ <[email protected]>
AuthorDate: Wed Jan 5 16:39:25 2022 +0900
Commit:     Katayama Hirofumi MZ <[email protected]>
CommitDate: Wed Jan 5 16:41:12 2022 +0900

    [MSPAINT] Follow-up of #4237
    
    CORE-17949
---
 base/applications/mspaint/dialogs.cpp | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/base/applications/mspaint/dialogs.cpp 
b/base/applications/mspaint/dialogs.cpp
index a21fb45db69..2b0798f7ef9 100644
--- a/base/applications/mspaint/dialogs.cpp
+++ b/base/applications/mspaint/dialogs.cpp
@@ -576,10 +576,14 @@ LRESULT CFontsDialog::OnDrawItem(UINT nMsg, WPARAM 
wParam, LPARAM lParam, BOOL&
         }
 
         TCHAR szText[LF_FACESIZE];
-        szText[0] = 0;
-        ComboBox_GetLBText(hwndItem, pDrawItem->itemID, szText);
-        rcItem.left += 24;
-        DrawText(pDrawItem->hDC, szText, -1, &rcItem, DT_LEFT | DT_VCENTER | 
DT_SINGLELINE);
+        if ((UINT)ComboBox_GetLBTextLen(hwndItem, pDrawItem->itemID) < 
_countof(szText))
+        {
+            szText[0] = 0;
+            ComboBox_GetLBText(hwndItem, pDrawItem->itemID, szText);
+
+            rcItem.left += 24;
+            DrawText(pDrawItem->hDC, szText, -1, &rcItem, DT_LEFT | DT_VCENTER 
| DT_SINGLELINE);
+        }
 
         if (pDrawItem->itemState & ODS_FOCUS)
             ::DrawFocusRect(pDrawItem->hDC, &pDrawItem->rcItem);

Reply via email to