On 08.03.2017 11:25, Hans Leidekker wrote:
- if ((hr = write_set_element_namespace( writer )) != S_OK) goto done;
- if ((hr = write_startelement( writer )) != S_OK) goto done;
- if ((hr = write_endstartelement( writer )) != S_OK) goto done; writer->state = WRITER_STATE_ENDSTARTELEMENT;
+done:
- LeaveCriticalSection( &writer->cs ); return S_OK;
You should return hr here.
for (i = offset; i < count; i++) { const char *ptr = (const char *)array + (offset + i) * type_size;
if ((hr = write_element_node( writer, NULL, localname, ns )) != S_OK) return hr;
if ((hr = write_element_node( writer, NULL, localname, ns )) != S_OK) goto done; if ((hr = write_type( writer, WS_ELEMENT_TYPE_MAPPING, type, NULL, WS_WRITE_REQUIRED_POINTER,
&ptr, sizeof(ptr) )) != S_OK) return hr;
if ((hr = write_endelement_node( writer )) != S_OK) return hr;
&ptr, sizeof(ptr) )) != S_OK) goto done;
}if ((hr = write_endelement_node( writer )) != S_OK) goto done;
- return S_OK;
+done:
- LeaveCriticalSection( &writer->cs );
- return hr;
It looks like hr will be undefined here if count == 0
}
/************************************************************************** @@ -2392,9 +2662,20 @@ HRESULT WINAPI WsWriteXmlBuffer( WS_XML_WRITER *handle, WS_XML_BUFFER *buffer, W
if (!writer || !xmlbuf) return E_INVALIDARG;
- if ((hr = write_flush( writer )) != S_OK) return hr;
- if ((hr = write_grow_buffer( writer, xmlbuf->size )) != S_OK) return hr;
- EnterCriticalSection( &writer->cs );
- if (writer->magic != WRITER_MAGIC)
- {
LeaveCriticalSection( &writer->cs );
return E_INVALIDARG;
- }
- if ((hr = write_flush( writer )) != S_OK) goto done;
- if ((hr = write_grow_buffer( writer, xmlbuf->size )) != S_OK) goto done; write_bytes( writer, xmlbuf->ptr, xmlbuf->size );
+done:
- LeaveCriticalSection( &writer->cs ); return S_OK;
Here you should also use hr.