From: Piotr Caban Subject: [PATCH v2] msvcp90: Call invalid_parameter_handler on index out of range in basic_string::operator[] Message-Id: <54209316-cd67-c8c9-78ac-e68c403b66ff@codeweavers.com> Date: Fri, 5 May 2017 20:28:09 +0200 v2: - there's no arguments validation in msvcp70/msvcp71 Signed-off-by: Piotr Caban --- dlls/msvcp90/string.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/dlls/msvcp90/string.c b/dlls/msvcp90/string.c index e102020..317373b 100644 --- a/dlls/msvcp90/string.c +++ b/dlls/msvcp90/string.c @@ -22,7 +22,6 @@ #include "msvcp90.h" #include "stdio.h" -#include "assert.h" #include "windef.h" #include "winbase.h" @@ -1979,7 +1978,11 @@ char* __thiscall MSVCP_basic_string_char_operator_at( { TRACE("%p %lu\n", this, pos); - assert(this->size >= pos); +#if _MSVCP_VER >= 80 + if (this->size < pos) + _invalid_parameter(NULL, NULL, NULL, 0, 0); +#endif + return basic_string_char_ptr(this)+pos; } @@ -1991,7 +1994,11 @@ const char* __thiscall MSVCP_basic_string_char_const_operator_at( { TRACE("%p %lu\n", this, pos); - assert(this->size >= pos); +#if _MSVCP_VER >= 80 + if (this->size < pos) + _invalid_parameter(NULL, NULL, NULL, 0, 0); +#endif + return basic_string_char_const_ptr(this)+pos; } @@ -3951,7 +3958,11 @@ wchar_t* __thiscall MSVCP_basic_string_wchar_operator_at( { TRACE("%p %lu\n", this, pos); - assert(this->size >= pos); +#if _MSVCP_VER >= 80 + if (this->size < pos) + _invalid_parameter(NULL, NULL, NULL, 0, 0); +#endif + return basic_string_wchar_ptr(this)+pos; } @@ -3965,7 +3976,11 @@ const wchar_t* __thiscall MSVCP_basic_string_wchar_const_operator_at( { TRACE("%p %lu\n", this, pos); - assert(this->size >= pos); +#if _MSVCP_VER >= 80 + if (this->size < pos) + _invalid_parameter(NULL, NULL, NULL, 0, 0); +#endif + return basic_string_wchar_const_ptr(this)+pos; }