diff --git a/dlls/webservices/tests/writer.c b/dlls/webservices/tests/writer.c
index 5c865950f31..0d5fa2a0e24 100644
--- a/dlls/webservices/tests/writer.c
+++ b/dlls/webservices/tests/writer.c
@@ -395,7 +395,7 @@ static void test_WsWriteStartElement(void)
HRESULT hr;
WS_XML_WRITER *writer;
WS_XML_STRING prefix = {1, (BYTE *)"p"}, ns = {2, (BYTE *)"ns"}, ns2 = {3, (BYTE *)"ns2"};
- WS_XML_STRING localname = {1, (BYTE *)"a"}, localname2 = {1, (BYTE *)"b"};
+ WS_XML_STRING localname = {1, (BYTE *)"a"}, localname2 = {1, (BYTE *)"b"}, empty = {0, NULL};
hr = WsCreateWriter( NULL, 0, &writer, NULL );
ok( hr == S_OK, "got %08x\n", hr );
@@ -469,6 +469,17 @@ static void test_WsWriteStartElement(void)
ok( hr == S_OK, "got %08x\n", hr );
check_output( writer, "", __LINE__ );
+ hr = set_output( writer );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ hr = WsWriteStartElement( writer, &empty, &localname, &empty, NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+ hr = WsWriteEndStartElement( writer, NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+ hr = WsWriteEndElement( writer, NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+ check_output( writer, "", __LINE__ );
+
WsFreeWriter( writer );
}
@@ -476,7 +487,8 @@ static void test_WsWriteStartAttribute(void)
{
HRESULT hr;
WS_XML_WRITER *writer;
- WS_XML_STRING prefix = {1, (BYTE *)"p"}, localname = {3, (BYTE *)"str"}, ns = {2, (BYTE *)"ns"};
+ WS_XML_STRING prefix = {1, (BYTE *)"p"}, localname = {3, (BYTE *)"str"};
+ WS_XML_STRING localname2 = {3, (BYTE *)"len"}, ns = {2, (BYTE *)"ns"}, empty = {0, NULL};
WS_XML_UTF8_TEXT text = {{WS_XML_TEXT_TYPE_UTF8}};
hr = WsCreateWriter( NULL, 0, &writer, NULL );
@@ -492,9 +504,7 @@ static void test_WsWriteStartAttribute(void)
ok( hr == E_INVALIDARG, "got %08x\n", hr );
/* WsWriteStartAttribute doesn't output anything */
- localname.length = 3;
- localname.bytes = (BYTE *)"len";
- hr = WsWriteStartAttribute( writer, &prefix, &localname, &ns, FALSE, NULL );
+ hr = WsWriteStartAttribute( writer, &prefix, &localname2, &ns, FALSE, NULL );
ok( hr == S_OK, "got %08x\n", hr );
check_output( writer, "", __LINE__ );
@@ -513,6 +523,21 @@ static void test_WsWriteStartAttribute(void)
ok( hr == S_OK, "got %08x\n", hr );
check_output( writer, "", __LINE__ );
+ hr = set_output( writer );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ hr = WsWriteStartElement( writer, &prefix, &localname, &ns, NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ hr = WsWriteStartAttribute( writer, &empty, &localname2, &empty, FALSE, NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+ hr = WsWriteEndAttribute( writer, NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ hr = WsWriteEndElement( writer, NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+ check_output( writer, "", __LINE__ );
+
WsFreeWriter( writer );
}
diff --git a/dlls/webservices/writer.c b/dlls/webservices/writer.c
index 74b6efde128..5902f45ffa5 100644
--- a/dlls/webservices/writer.c
+++ b/dlls/webservices/writer.c
@@ -518,12 +518,12 @@ static HRESULT write_attribute( struct writer *writer, WS_XML_ATTRIBUTE *attr )
/* ' prefix:attr="value"' */
size = attr->localName->length + 4 /* ' =""' */;
- if (prefix) size += prefix->length + 1 /* ':' */;
+ if (prefix && prefix->length) size += prefix->length + 1 /* ':' */;
if (text) size += text->value.length;
if ((hr = write_grow_buffer( writer, size )) != S_OK) return hr;
write_char( writer, ' ' );
- if (prefix)
+ if (prefix && prefix->length)
{
write_bytes( writer, prefix->bytes, prefix->length );
write_char( writer, ':' );
@@ -734,11 +734,11 @@ static HRESULT write_startelement( struct writer *writer )
/* 'localName->length + 1 /* '<' */;
- if (elem->prefix) size += elem->prefix->length + 1 /* ':' */;
+ if (elem->prefix && elem->prefix->length) size += elem->prefix->length + 1 /* ':' */;
if ((hr = write_grow_buffer( writer, size )) != S_OK) return hr;
write_char( writer, '<' );
- if (elem->prefix)
+ if (elem->prefix && elem->prefix->length)
{
write_bytes( writer, elem->prefix->bytes, elem->prefix->length );
write_char( writer, ':' );
@@ -796,12 +796,12 @@ static HRESULT write_endelement( struct writer *writer, const WS_XML_ELEMENT_NOD
/* '' */
size = elem->localName->length + 3 /* '>' */;
- if (elem->prefix) size += elem->prefix->length + 1 /* ':' */;
+ if (elem->prefix && elem->prefix->length) size += elem->prefix->length + 1 /* ':' */;
if ((hr = write_grow_buffer( writer, size )) != S_OK) return hr;
write_char( writer, '<' );
write_char( writer, '/' );
- if (elem->prefix)
+ if (elem->prefix && elem->prefix->length)
{
write_bytes( writer, elem->prefix->bytes, elem->prefix->length );
write_char( writer, ':' );