Piotr Caban : msvcp90: Call invalid_parameter_handler on index out of range in basic_string:: operator[].

Alexandre Julliard julliard at winehq.org
Mon May 8 17:21:22 CDT 2017


Module: wine
Branch: master
Commit: a5767dc3ef7d5af5f966369c8d4a090c5c7e305f
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=a5767dc3ef7d5af5f966369c8d4a090c5c7e305f

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Fri May  5 20:28:09 2017 +0200

msvcp90: Call invalid_parameter_handler on index out of range in basic_string::operator[].

Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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;
 }
 




More information about the wine-cvs mailing list