Commit 20920457 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

xmllite/tests: Fix a memory leak (Valgrind).

parent c7fb64db
......@@ -31,6 +31,15 @@
#include "initguid.h"
DEFINE_GUID(IID_IXmlWriterOutput, 0xc1131708, 0x0f59, 0x477f, 0x93, 0x59, 0x7d, 0x33, 0x24, 0x51, 0xbc, 0x1a);
#define EXPECT_REF(obj, ref) _expect_ref((IUnknown *)obj, ref, __LINE__)
static void _expect_ref(IUnknown *obj, ULONG ref, int line)
{
ULONG refcount;
IUnknown_AddRef(obj);
refcount = IUnknown_Release(obj);
ok_(__FILE__, line)(refcount == ref, "expected refcount %d, got %d\n", ref, refcount);
}
static void check_output(IStream *stream, const char *expected, BOOL todo, int line)
{
int len = strlen(expected), size;
......@@ -273,6 +282,7 @@ static void test_writeroutput(void)
output = NULL;
hr = CreateXmlWriterOutputWithEncodingName(&testoutput, NULL, NULL, &output);
ok(hr == S_OK, "got %08x\n", hr);
EXPECT_REF(output, 1);
IUnknown_Release(output);
hr = CreateXmlWriterOutputWithEncodingName(&testoutput, NULL, utf16W, &output);
......@@ -280,9 +290,13 @@ static void test_writeroutput(void)
unk = NULL;
hr = IUnknown_QueryInterface(output, &IID_IXmlWriterOutput, (void**)&unk);
ok(hr == S_OK, "got %08x\n", hr);
ok(unk != NULL, "got %p\n", unk);
todo_wine
ok(unk != NULL && unk != output, "got %p, output %p\n", unk, output);
EXPECT_REF(output, 2);
/* releasing 'unk' crashes on native */
IUnknown_Release(output);
EXPECT_REF(output, 1);
IUnknown_Release(output);
output = NULL;
hr = CreateXmlWriterOutputWithEncodingCodePage(&testoutput, NULL, ~0u, &output);
......@@ -297,6 +311,7 @@ static void test_writeroutput(void)
ok(unk != NULL, "got %p\n", unk);
/* releasing 'unk' crashes on native */
IUnknown_Release(output);
IUnknown_Release(output);
}
static void test_writestartdocument(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment