Fixed possible endless loop.

diff --git a/windows/dialog.c b/windows/dialog.c
index cfc1bb7..bd52d89 100644
--- a/windows/dialog.c
+++ b/windows/dialog.c
@@ -1045,11 +1045,12 @@
         do
         {
             wndPtr = WIN_FindWndPtr( hwndControl );
-            if (wndPtr != NULL && wndPtr->text != NULL && 
-                    (wndPtr->dwStyle & (WS_VISIBLE | WS_DISABLED)) == WS_VISIBLE)
+            if ( (wndPtr != NULL) && 
+                 ((wndPtr->dwStyle & (WS_VISIBLE | WS_DISABLED)) == WS_VISIBLE) )
             {
                 dlgCode = SendMessageA( hwndControl, WM_GETDLGCODE, 0, 0 );
-                if (dlgCode & (DLGC_BUTTON | DLGC_STATIC))
+                if ( (dlgCode & (DLGC_BUTTON | DLGC_STATIC)) && 
+                     (wndPtr->text!=NULL))
                 {
                     /* find the accelerator key */
                     LPSTR p = wndPtr->text - 2;