From 9d6c003cd7bb059777b5c931c4843be68560218b Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Mon, 22 Oct 2012 17:15:49 +0200 Subject: [PATCH] msvcp60: Copy correct number of characters in basic_string::_Grow. --- dlls/msvcp60/string.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/dlls/msvcp60/string.c b/dlls/msvcp60/string.c index 591ffdf41e8..ed4391c7cc6 100644 --- a/dlls/msvcp60/string.c +++ b/dlls/msvcp60/string.c @@ -203,13 +203,16 @@ MSVCP_bool __thiscall basic_string_char__Grow(basic_string_char *this, MSVCP_siz return FALSE; } + if(len > new_res) + len = new_res; + *ptr = 0; if(this->ptr) - char_traits_char__Copy_s(ptr+1, new_size, this->ptr, this->size); + char_traits_char__Copy_s(ptr+1, new_size, this->ptr, len); basic_string_char__Tidy(this, TRUE); this->ptr = ptr+1; this->res = new_res; - basic_string_char__Eos(this, len>new_res ? new_res : len); + basic_string_char__Eos(this, len); } return new_size>0; @@ -1911,13 +1914,16 @@ MSVCP_bool __thiscall basic_string_wchar__Grow(basic_string_wchar *this, MSVCP_s return FALSE; } + if(len > new_res) + len = new_res; + *ptr = 0; if(this->ptr) - char_traits_wchar__Copy_s(ptr+1, new_size, this->ptr, this->size); + char_traits_wchar__Copy_s(ptr+1, new_size, this->ptr, len); basic_string_wchar__Tidy(this, TRUE); this->ptr = ptr+1; this->res = new_res; - basic_string_wchar__Eos(this, len>new_res ? new_res : len); + basic_string_wchar__Eos(this, len); } return new_size>0;