From: Piotr Caban Subject: [PATCH] msvcp90: Don't overwrite pointers to class members in basic_streambuf:swap Message-Id: <7cfedd72-9a73-563f-2d82-c2211d3ac1a1@codeweavers.com> Date: Wed, 3 May 2017 16:03:28 +0200 Signed-off-by: Piotr Caban --- dlls/msvcp90/ios.c | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/dlls/msvcp90/ios.c b/dlls/msvcp90/ios.c index 84a6bf2c..9b17bf2 100644 --- a/dlls/msvcp90/ios.c +++ b/dlls/msvcp90/ios.c @@ -2002,18 +2002,33 @@ streamsize __thiscall basic_streambuf_char_sputn(basic_streambuf_char *this, con DEFINE_THISCALL_WRAPPER(basic_streambuf_char_swap, 8) void __thiscall basic_streambuf_char_swap(basic_streambuf_char *this, basic_streambuf_char *r) { - basic_streambuf_char tmp; + char *wfirst, *wnext, *wlast, *rfirst, *rnext, *rlast; +#if _MSVCP_VER < 70 + locale loc; +#else + locale *loc; +#endif TRACE("(%p %p)\n", this, r); if(this == r) return; - tmp = *this; - *this = *r; - this->vtable = tmp.vtable; - tmp.vtable = r->vtable; - *r = tmp; + wfirst = *this->pwbuf; + wnext = *this->pwpos; + wlast = *this->pwpos + *this->pwsize; + rfirst = *this->prbuf; + rnext = *this->prpos; + rlast = *this->prpos + *this->prsize; + loc = this->loc; + + basic_streambuf_char_setp_next(this, *r->pwbuf, *r->pwpos, *r->pwpos + *r->pwsize); + basic_streambuf_char_setg(this, *r->prbuf, *r->prpos, *r->prpos + *r->prsize); + this->loc = r->loc; + + basic_streambuf_char_setp_next(r, wfirst, wnext, wlast); + basic_streambuf_char_setg(r, rfirst, rnext, rlast); + r->loc = loc; } /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W00@Z */ @@ -2967,10 +2982,13 @@ void __thiscall basic_streambuf_wchar_swap(basic_streambuf_wchar *this, basic_st return; tmp = *this; - *this = *r; - this->vtable = tmp.vtable; - tmp.vtable = r->vtable; - *r = tmp; + basic_streambuf_wchar_setp_next(this, *r->pwbuf, *r->pwpos, *r->pwpos + *r->pwsize); + basic_streambuf_wchar_setg(this, *r->prbuf, *r->prpos, *r->prpos + *r->prsize); + this->loc = r->loc; + + basic_streambuf_wchar_setp_next(r, *tmp.pwbuf, *tmp.pwpos, *tmp.pwpos + *tmp.pwsize); + basic_streambuf_wchar_setg(r, *tmp.prbuf, *tmp.prpos, *tmp.prpos + *tmp.prsize); + r->loc = tmp.loc; } /* ?_Stinit@?1??_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@23@@Z@4HA */