Commit 8e9e82f4 authored by Dan Kegel's avatar Dan Kegel Committed by Alexandre Julliard

msvcp90: Handle npos as length in more places.

parent 5befb959
......@@ -1331,7 +1331,7 @@ int __thiscall MSVCP_basic_string_char_compare_substr_cstr_len(
if(this->size < pos)
MSVCP__String_base_Xran();
if(pos+num > this->size)
if(num > this->size-pos)
num = this->size-pos;
ans = MSVCP_char_traits_char_compare(basic_string_char_const_ptr(this)+pos,
......@@ -1378,7 +1378,7 @@ int __thiscall MSVCP_basic_string_char_compare_substr_substr(
if(compare->size < off)
MSVCP__String_base_Xran();
if(off+count > compare->size)
if(count > compare->size-off)
count = compare->size-off;
return MSVCP_basic_string_char_compare_substr_cstr_len(this, pos, num,
......@@ -2017,7 +2017,7 @@ basic_string_char* __thiscall basic_string_char_replace_substr(basic_string_char
if(str->size < str_off)
MSVCP__String_base_Xran();
if(str_off+str_len > str->size)
if(str_len > str->size-str_off)
str_len = str->size-str_off;
return basic_string_char_replace_cstr_len(this, off, len,
......@@ -3265,7 +3265,7 @@ int __thiscall MSVCP_basic_string_wchar_compare_substr_cstr_len(
if(this->size < pos)
MSVCP__String_base_Xran();
if(pos+num > this->size)
if(num > this->size-pos)
num = this->size-pos;
ans = MSVCP_char_traits_wchar_compare(basic_string_wchar_const_ptr(this)+pos,
......@@ -3318,7 +3318,7 @@ int __thiscall MSVCP_basic_string_wchar_compare_substr_substr(
if(compare->size < off)
MSVCP__String_base_Xran();
if(off+count > compare->size)
if(count > compare->size-off)
count = compare->size-off;
return MSVCP_basic_string_wchar_compare_substr_cstr_len(this, pos, num,
......@@ -3980,7 +3980,7 @@ basic_string_wchar* __thiscall basic_string_wchar_replace_substr(basic_string_wc
if(str->size < str_off)
MSVCP__String_base_Xran();
if(str_off+str_len > str->size)
if(str_len > str->size-str_off)
str_len = str->size-str_off;
return basic_string_wchar_replace_cstr_len(this, off, len,
......
......@@ -17,6 +17,7 @@
*/
#include <stdio.h>
#include <limits.h>
#include <windef.h>
#include <winbase.h>
......@@ -450,11 +451,12 @@ static void test_basic_string_char_append(void) {
}
static void test_basic_string_char_compare(void) {
basic_string_char str1, str2;
basic_string_char str1, str2, str3;
int ret;
call_func2(p_basic_string_char_ctor_cstr, &str1, "str1str");
call_func2(p_basic_string_char_ctor_cstr, &str2, "str9str");
call_func2(p_basic_string_char_ctor_cstr, &str3, "splash.png");
ret = (int)call_func6(p_basic_string_char_compare_substr_substr,
&str1, 0, 3, &str2, 0, 3);
......@@ -470,6 +472,9 @@ static void test_basic_string_char_compare(void) {
&str1, 0, 1000, "str1str", 7);
ok(ret == 0, "ret = %d\n", ret);
ret = (int)call_func5(p_basic_string_char_compare_substr_cstr_len,
&str3, 6, UINT_MAX, ".png", 4);
ok(ret == 0, "ret = %d\n", ret);
ret = (int)call_func5(p_basic_string_char_compare_substr_cstr_len,
&str1, 1, 2, "tr", 2);
ok(ret == 0, "ret = %d\n", ret);
ret = (int)call_func5(p_basic_string_char_compare_substr_cstr_len,
......@@ -481,6 +486,7 @@ static void test_basic_string_char_compare(void) {
call_func1(p_basic_string_char_dtor, &str1);
call_func1(p_basic_string_char_dtor, &str2);
call_func1(p_basic_string_char_dtor, &str3);
}
static void test_basic_string_char_concatenate(void) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment