mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-24 13:33:01 +03:00
io: Make xmlOutputBufferCreate* not free encoder on error
Revert a530ff12 which was an inadvertent API change.
This commit is contained in:
26
xmlIO.c
26
xmlIO.c
@@ -1509,7 +1509,7 @@ xmlAllocParserInputBuffer(xmlCharEncoding enc) {
|
||||
/**
|
||||
* Create a buffered parser output
|
||||
*
|
||||
* Consumes `encoder` even in error case.
|
||||
* Consumes `encoder` but not in error case.
|
||||
*
|
||||
* @param encoder the encoding converter or NULL
|
||||
* @returns the new parser output or NULL
|
||||
@@ -1520,13 +1520,11 @@ xmlAllocOutputBuffer(xmlCharEncodingHandlerPtr encoder) {
|
||||
|
||||
ret = (xmlOutputBufferPtr) xmlMalloc(sizeof(xmlOutputBuffer));
|
||||
if (ret == NULL) {
|
||||
xmlCharEncCloseFunc(encoder);
|
||||
return(NULL);
|
||||
}
|
||||
memset(ret, 0, sizeof(xmlOutputBuffer));
|
||||
ret->buffer = xmlBufCreate(MINLEN);
|
||||
if (ret->buffer == NULL) {
|
||||
xmlCharEncCloseFunc(encoder);
|
||||
xmlFree(ret);
|
||||
return(NULL);
|
||||
}
|
||||
@@ -1535,7 +1533,8 @@ xmlAllocOutputBuffer(xmlCharEncodingHandlerPtr encoder) {
|
||||
if (encoder != NULL) {
|
||||
ret->conv = xmlBufCreate(MINLEN);
|
||||
if (ret->conv == NULL) {
|
||||
xmlOutputBufferClose(ret);
|
||||
xmlBufFree(ret->buffer);
|
||||
xmlFree(ret);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
@@ -1778,7 +1777,6 @@ __xmlOutputBufferCreateFilename(const char *URI,
|
||||
* Allocate the Output buffer front-end.
|
||||
*/
|
||||
ret = xmlAllocOutputBuffer(encoder);
|
||||
encoder = NULL;
|
||||
if (ret == NULL)
|
||||
goto error;
|
||||
|
||||
@@ -1807,14 +1805,14 @@ __xmlOutputBufferCreateFilename(const char *URI,
|
||||
}
|
||||
|
||||
if (ret->context == NULL) {
|
||||
/* Don't free encoder */
|
||||
ret->encoder = NULL;
|
||||
xmlOutputBufferClose(ret);
|
||||
ret = NULL;
|
||||
}
|
||||
|
||||
error:
|
||||
xmlFree(unescaped);
|
||||
if (encoder != NULL)
|
||||
xmlCharEncCloseFunc(encoder);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@@ -1824,7 +1822,7 @@ error:
|
||||
* Automatic support for ZLIB/Compress compressed document is provided
|
||||
* by default if found at compile-time.
|
||||
*
|
||||
* Consumes `encoder` even in error case.
|
||||
* Consumes `encoder` but not in error case.
|
||||
*
|
||||
* @param URI a C string containing the URI or filename
|
||||
* @param encoder the encoding converter or NULL
|
||||
@@ -1877,7 +1875,7 @@ xmlParserInputBufferCreateFile(FILE *file, xmlCharEncoding enc) {
|
||||
* Create a buffered output for the progressive saving to a `FILE *`
|
||||
* buffered C I/O.
|
||||
*
|
||||
* Consumes `encoder` even in error case.
|
||||
* Consumes `encoder` but not in error case.
|
||||
*
|
||||
* @param file a `FILE *`
|
||||
* @param encoder the encoding converter or NULL
|
||||
@@ -1888,7 +1886,6 @@ xmlOutputBufferCreateFile(FILE *file, xmlCharEncodingHandlerPtr encoder) {
|
||||
xmlOutputBufferPtr ret;
|
||||
|
||||
if (file == NULL) {
|
||||
xmlCharEncCloseFunc(encoder);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
@@ -1905,7 +1902,7 @@ xmlOutputBufferCreateFile(FILE *file, xmlCharEncodingHandlerPtr encoder) {
|
||||
/**
|
||||
* Create a buffered output for the progressive saving to a xmlBuffer
|
||||
*
|
||||
* Consumes `encoder` even in error case.
|
||||
* Consumes `encoder` but not in error case.
|
||||
*
|
||||
* @param buffer a xmlBufferPtr
|
||||
* @param encoder the encoding converter or NULL
|
||||
@@ -1917,7 +1914,6 @@ xmlOutputBufferCreateBuffer(xmlBufferPtr buffer,
|
||||
xmlOutputBufferPtr ret;
|
||||
|
||||
if (buffer == NULL) {
|
||||
xmlCharEncCloseFunc(encoder);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
@@ -2167,7 +2163,7 @@ xmlNewInputBufferString(const char *str, xmlParserInputFlags flags) {
|
||||
* Create a buffered output for the progressive saving
|
||||
* to a file descriptor
|
||||
*
|
||||
* Consumes `encoder` even in error case.
|
||||
* Consumes `encoder` but not in error case.
|
||||
*
|
||||
* @param fd a file descriptor number
|
||||
* @param encoder the encoding converter or NULL
|
||||
@@ -2178,7 +2174,6 @@ xmlOutputBufferCreateFd(int fd, xmlCharEncodingHandlerPtr encoder) {
|
||||
xmlOutputBufferPtr ret;
|
||||
|
||||
if (fd < 0) {
|
||||
xmlCharEncCloseFunc(encoder);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
@@ -2239,7 +2234,7 @@ xmlParserInputBufferCreateIO(xmlInputReadCallback ioread,
|
||||
* Create a buffered output for the progressive saving
|
||||
* to an I/O handler
|
||||
*
|
||||
* Consumes `encoder` even in error case.
|
||||
* Consumes `encoder` but not in error case.
|
||||
*
|
||||
* @param iowrite an I/O write function
|
||||
* @param ioclose an I/O close function
|
||||
@@ -2254,7 +2249,6 @@ xmlOutputBufferCreateIO(xmlOutputWriteCallback iowrite,
|
||||
xmlOutputBufferPtr ret;
|
||||
|
||||
if (iowrite == NULL) {
|
||||
xmlCharEncCloseFunc(encoder);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user