Piotr Caban : msvcirt: Fix leak in ~ios and ios::init implementation.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Jul 8 09:51:23 CDT 2015
Module: wine
Branch: master
Commit: 4406762dc283d00c93a6433c7da7e9dca4b9d14f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=4406762dc283d00c93a6433c7da7e9dca4b9d14f
Author: Piotr Caban <piotr at codeweavers.com>
Date: Wed Jul 8 10:28:59 2015 +0200
msvcirt: Fix leak in ~ios and ios::init implementation.
---
dlls/msvcirt/msvcirt.c | 6 ++++--
dlls/msvcirt/tests/msvcirt.c | 8 +++++---
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/dlls/msvcirt/msvcirt.c b/dlls/msvcirt/msvcirt.c
index 04c195d..c740049 100644
--- a/dlls/msvcirt/msvcirt.c
+++ b/dlls/msvcirt/msvcirt.c
@@ -172,6 +172,8 @@ streambuf* __thiscall streambuf_assign(streambuf *this, const streambuf *rhs)
/* ??_Estreambuf@@UAEPAXI at Z */
DEFINE_THISCALL_WRAPPER(streambuf_vector_dtor, 8)
+#define call_streambuf_vector_dtor(this, flags) CALL_VTBL_FUNC(this, 0,\
+ streambuf*, (streambuf*, unsigned int), (this, flags))
streambuf* __thiscall streambuf_vector_dtor(streambuf *this, unsigned int flags)
{
TRACE("(%p %x)\n", this, flags);
@@ -753,7 +755,7 @@ void __thiscall ios_dtor(ios *this)
{
TRACE("(%p)\n", this);
if (this->delbuf && this->sb)
- MSVCRT_operator_delete(this->sb);
+ call_streambuf_vector_dtor(this->sb, 1);
this->sb = NULL;
this->state = IOSTATE_badbit;
DeleteCriticalSection(&this->lock);
@@ -958,7 +960,7 @@ void __thiscall ios_init(ios *this, streambuf *sb)
{
TRACE("(%p %p)\n", this, sb);
if (this->delbuf && this->sb)
- MSVCRT_operator_delete(this->sb);
+ call_streambuf_vector_dtor(this->sb, 1);
this->sb = sb;
if (sb == NULL)
this->state |= IOSTATE_badbit;
diff --git a/dlls/msvcirt/tests/msvcirt.c b/dlls/msvcirt/tests/msvcirt.c
index aded18f..bb5a5ed 100644
--- a/dlls/msvcirt/tests/msvcirt.c
+++ b/dlls/msvcirt/tests/msvcirt.c
@@ -813,8 +813,8 @@ static void test_ios(void)
memset(&ios_obj, 0xab, sizeof(ios));
memset(&ios_obj2, 0xab, sizeof(ios));
psb = p_operator_new(sizeof(streambuf));
- if (psb)
- call_func1(p_streambuf_ctor, psb);
+ ok(psb != NULL, "failed to allocate streambuf object\n");
+ call_func1(p_streambuf_ctor, psb);
/* constructor/destructor */
call_func2(p_ios_sb_ctor, &ios_obj, NULL);
@@ -857,10 +857,12 @@ static void test_ios(void)
ok(ios_obj.sb == NULL, "expected %p got %p\n", NULL, ios_obj.sb);
ok(ios_obj.state == (0x8|IOSTATE_badbit), "expected %x got %x\n", (0x8|IOSTATE_badbit), ios_obj.state);
ios_obj.sb = psb;
- ios_obj.delbuf = 1;
+ ios_obj.delbuf = 0;
call_func2(p_ios_init, &ios_obj, psb);
ok(ios_obj.sb == psb, "expected %p got %p\n", psb, ios_obj.sb);
ok(ios_obj.state == 0x8, "expected %x got %x\n", 0x8, ios_obj.state);
+ ios_obj.delbuf = 1;
+ call_func1(p_ios_dtor, &ios_obj);
/* copy constructor */
call_func2(p_ios_copy_ctor, &ios_obj, &ios_obj2);
More information about the wine-cvs
mailing list