msvcirt: Fix leak in ~ios and ios::init implementation.
This commit is contained in:
parent
849bb99b76
commit
4406762dc2
|
@ -172,6 +172,8 @@ streambuf* __thiscall streambuf_assign(streambuf *this, const streambuf *rhs)
|
|||
|
||||
/* ??_Estreambuf@@UAEPAXI@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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue