Module: wine Branch: master Commit: 8e9e82f41eb0470de154d6b6a583fa15ea4ed176 URL: http://source.winehq.org/git/wine.git/?a=commit;h=8e9e82f41eb0470de154d6b6a5...
Author: Dan Kegel dank@kegel.com Date: Sat Sep 8 07:59:44 2012 -0700
msvcp90: Handle npos as length in more places.
---
dlls/msvcp90/string.c | 12 ++++++------ dlls/msvcp90/tests/string.c | 8 +++++++- 2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/dlls/msvcp90/string.c b/dlls/msvcp90/string.c index fb2ba1a..740681f 100644 --- a/dlls/msvcp90/string.c +++ b/dlls/msvcp90/string.c @@ -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, diff --git a/dlls/msvcp90/tests/string.c b/dlls/msvcp90/tests/string.c index 1e3ccec..511d846 100644 --- a/dlls/msvcp90/tests/string.c +++ b/dlls/msvcp90/tests/string.c @@ -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) {