[COMCTL32] Sync with Wine Staging 1.7.55. CORE-10536
[reactos.git] / reactos / dll / win32 / comctl32 / syslink.c
index 7508519..1c7039c 100644 (file)
@@ -173,6 +173,26 @@ static VOID SYSLINK_ClearDoc (SYSLINK_INFO *infoPtr)
     infoPtr->Items = NULL;
 }
 
+/***********************************************************************
+ * SYSLINK_StrCmpNIW
+ * Wrapper for StrCmpNIW to ensure 'len' is not too big.
+ */
+static INT SYSLINK_StrCmpNIW (LPCWSTR str, LPCWSTR comp, INT len)
+{
+    INT i;
+
+    for(i = 0; i < len; i++)
+    {
+        if(!str[i])
+        {
+            len = i + 1;
+            break;
+        }
+    }
+
+    return StrCmpNIW(str, comp, len);
+}
+
 /***********************************************************************
  * SYSLINK_ParseText
  * Parses the window text string and creates a document. Returns the
@@ -193,7 +213,7 @@ static UINT SYSLINK_ParseText (SYSLINK_INFO *infoPtr, LPCWSTR Text)
     {
         if(*current == '<')
         {
-            if(!StrCmpNIW(current, SL_LINKOPEN, 2) && (CurrentType == slText))
+            if(!SYSLINK_StrCmpNIW(current, SL_LINKOPEN, 2) && (CurrentType == slText))
             {
                 BOOL ValidParam = FALSE, ValidLink = FALSE;
 
@@ -221,14 +241,14 @@ static UINT SYSLINK_ParseText (SYSLINK_INFO *infoPtr, LPCWSTR Text)
                     
 CheckParameter:
                     /* compare the current position with all known parameters */
-                    if(!StrCmpNIW(tmp, SL_HREF, 6))
+                    if(!SYSLINK_StrCmpNIW(tmp, SL_HREF, 6))
                     {
                         taglen += 6;
                         ValidParam = TRUE;
                         CurrentParameter = &lpUrl;
                         CurrentParameterLen = &lenUrl;
                     }
-                    else if(!StrCmpNIW(tmp, SL_ID, 4))
+                    else if(!SYSLINK_StrCmpNIW(tmp, SL_ID, 4))
                     {
                         taglen += 4;
                         ValidParam = TRUE;
@@ -302,7 +322,7 @@ CheckParameter:
                     }
                 }
             }
-            else if(!StrCmpNIW(current, SL_LINKCLOSE, 4) && (CurrentType == slLink) && firsttag)
+            else if(!SYSLINK_StrCmpNIW(current, SL_LINKCLOSE, 4) && (CurrentType == slLink) && firsttag)
             {
                 /* there's a <a...> tag opened, first add the previous text, if present */
                 if(textstart != NULL && textlen > 0 && firsttag > textstart)
@@ -1357,7 +1377,7 @@ static PDOC_ITEM SYSLINK_LinkAtPt (const SYSLINK_INFO *infoPtr, const POINT *pt,
     for(Current = infoPtr->Items; Current != NULL; Current = Current->Next)
     {
         if((Current->Type == slLink) && SYSLINK_PtInDocItem(Current, *pt) &&
-           (!MustBeEnabled || (MustBeEnabled && (Current->u.Link.state & LIS_ENABLED))))
+           (!MustBeEnabled || (Current->u.Link.state & LIS_ENABLED)))
         {
             if(LinkId != NULL)
             {