1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2026-01-26 21:41:34 +03:00

Fix xmlOutputBufferGetContent output when encoder is set.

The xmlOutputBufferGetContent function only returns the buffer attribute
of the _xmlOutputBuffer struct.
When the `encoder` attribute is set the content is stored in the `conv`
attribute after conversions are performed and the `buffer` attribute is
emptied. This causes the xmlOutputBufferGetContent to always return
empty when the `encoder` is set.

This patch fixes the function by returning the `conv` attribute when the
encoder is set.

Fixes: #991
This commit is contained in:
Iván Chavero
2025-09-28 13:57:28 -06:00
committed by Daniel García Moreno
parent 3b2d4638ec
commit 84b8530d85

10
xmlIO.c
View File

@@ -1824,9 +1824,12 @@ xmlOutputBufferCreateBuffer(xmlBuffer *buffer,
*/
const xmlChar *
xmlOutputBufferGetContent(xmlOutputBuffer *out) {
if ((out == NULL) || (out->buffer == NULL) || (out->error != 0))
if ((out == NULL) || (out->buffer == NULL) || ((out->encoder != NULL) && (out->conv == NULL)) || (out->error != 0))
return(NULL);
if (out->encoder != NULL)
return(xmlBufContent(out->conv));
return(xmlBufContent(out->buffer));
}
@@ -1838,9 +1841,12 @@ xmlOutputBufferGetContent(xmlOutputBuffer *out) {
*/
size_t
xmlOutputBufferGetSize(xmlOutputBuffer *out) {
if ((out == NULL) || (out->buffer == NULL) || (out->error != 0))
if ((out == NULL) || (out->buffer == NULL) || ((out->encoder != NULL) && (out->conv == NULL)) || (out->error != 0))
return(0);
if (out->encoder != NULL)
return(xmlBufUse(out->conv));
return(xmlBufUse(out->buffer));
}