summaryrefslogtreecommitdiff
path: root/src/pal/src/cruntime
diff options
context:
space:
mode:
authorMike Kaufman <mike-kaufman@users.noreply.github.com>2017-08-21 16:30:34 -0700
committerDan Moseley <danmose@microsoft.com>2017-08-21 16:30:34 -0700
commit358826b58e1863857d110b30abb32257171d1009 (patch)
tree496a41a80d6dfdd41ae864e700ca66f838501f08 /src/pal/src/cruntime
parent41a2b788cb77668d397e372df40c5215bf61bfa7 (diff)
downloadcoreclr-358826b58e1863857d110b30abb32257171d1009.tar.gz
coreclr-358826b58e1863857d110b30abb32257171d1009.tar.bz2
coreclr-358826b58e1863857d110b30abb32257171d1009.zip
Fixing wcsstr function to account for cases where search string is longer than remaining target string. (#13504)
Diffstat (limited to 'src/pal/src/cruntime')
-rw-r--r--src/pal/src/cruntime/wchar.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/pal/src/cruntime/wchar.cpp b/src/pal/src/cruntime/wchar.cpp
index 3de065e361..5b466960a6 100644
--- a/src/pal/src/cruntime/wchar.cpp
+++ b/src/pal/src/cruntime/wchar.cpp
@@ -1194,16 +1194,22 @@ PAL_wcsstr(
i = 0;
while (1)
{
- if (*(string + i) == 0 || *(strCharSet + i) == 0)
+ if (*(strCharSet + i) == 0)
{
ret = (wchar_16 *) string;
goto leave;
}
- if (*(string + i) != *(strCharSet + i))
+ else if (*(string + i) == 0)
+ {
+ ret = NULL;
+ goto leave;
+ }
+ else if (*(string + i) != *(strCharSet + i))
{
break;
}
- i++;
+
+ i++;
}
string++;
}