[PATCH] programs/winecfg: Fix a crash on empty size field in Desktop Integration

Nikolay Sivov nsivov at codeweavers.com
Fri Dec 11 07:44:14 CST 2015


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---

To reproduce simply focuse size field, and remove what's in it with
backspace - it will crash in atoi() once field is empty, at least on libc
version on my system.

 programs/winecfg/theme.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/programs/winecfg/theme.c b/programs/winecfg/theme.c
index 52e64eb..8db457f 100644
--- a/programs/winecfg/theme.c
+++ b/programs/winecfg/theme.c
@@ -1214,8 +1214,17 @@ ThemeDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
                             int index = SendDlgItemMessageW(hDlg, IDC_SYSPARAM_COMBO, CB_GETCURSEL, 0, 0);
 
                             index = SendDlgItemMessageW(hDlg, IDC_SYSPARAM_COMBO, CB_GETITEMDATA, index, 0);
-                            metrics[index].size = atoi(text);
-                            HeapFree(GetProcessHeap(), 0, text);
+
+                            if (text)
+                            {
+                                metrics[index].size = atoi(text);
+                                HeapFree(GetProcessHeap(), 0, text);
+                            }
+                            else
+                            {
+                                /* for empty string set to minimum value */
+                                SendDlgItemMessageW(hDlg, IDC_SYSPARAM_SIZE_UD, UDM_GETRANGE32, (WPARAM)&metrics[index].size, 0);
+                            }
 
                             SendMessageW(GetParent(hDlg), PSM_CHANGED, 0, 0);
                             break;
-- 
2.6.2




More information about the wine-patches mailing list