Nikolay Sivov : xmllite/tests: Fix a memory leak (Valgrind).
Alexandre Julliard
julliard at winehq.org
Wed Mar 8 16:01:40 CST 2017
Module: wine
Branch: master
Commit: 20920457d709515b5915e5495bd92ffa082d096a
URL: http://source.winehq.org/git/wine.git/?a=commit;h=20920457d709515b5915e5495bd92ffa082d096a
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Wed Mar 8 22:46:54 2017 +0300
xmllite/tests: Fix a memory leak (Valgrind).
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/xmllite/tests/writer.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/dlls/xmllite/tests/writer.c b/dlls/xmllite/tests/writer.c
index 2a97a75..0508466 100644
--- a/dlls/xmllite/tests/writer.c
+++ b/dlls/xmllite/tests/writer.c
@@ -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)
More information about the wine-cvs
mailing list