@@ -1474,15 +1474,15 @@ xmlOutputBufferPtr
1474
1474
__xmlOutputBufferCreateFilename (const char * URI ,
1475
1475
xmlCharEncodingHandlerPtr encoder ,
1476
1476
int compression ) {
1477
- xmlOutputBufferPtr ret ;
1477
+ xmlOutputBufferPtr ret = NULL ;
1478
1478
xmlURIPtr puri ;
1479
1479
int i = 0 ;
1480
1480
char * unescaped = NULL ;
1481
1481
1482
1482
xmlInitParser ();
1483
1483
1484
1484
if (URI == NULL )
1485
- return ( NULL ) ;
1485
+ goto error ;
1486
1486
1487
1487
puri = xmlParseURI (URI );
1488
1488
if (puri != NULL ) {
@@ -1493,8 +1493,7 @@ __xmlOutputBufferCreateFilename(const char *URI,
1493
1493
unescaped = xmlURIUnescapeString (URI , 0 , NULL );
1494
1494
if (unescaped == NULL ) {
1495
1495
xmlFreeURI (puri );
1496
- xmlCharEncCloseFunc (encoder );
1497
- return (NULL );
1496
+ goto error ;
1498
1497
}
1499
1498
URI = unescaped ;
1500
1499
}
@@ -1505,10 +1504,9 @@ __xmlOutputBufferCreateFilename(const char *URI,
1505
1504
* Allocate the Output buffer front-end.
1506
1505
*/
1507
1506
ret = xmlAllocOutputBuffer (encoder );
1508
- if (ret == NULL ) {
1509
- xmlFree (unescaped );
1510
- return (NULL );
1511
- }
1507
+ encoder = NULL ;
1508
+ if (ret == NULL )
1509
+ goto error ;
1512
1510
1513
1511
/*
1514
1512
* Try to find one of the output accept method accepting that scheme
@@ -1539,7 +1537,10 @@ __xmlOutputBufferCreateFilename(const char *URI,
1539
1537
ret = NULL ;
1540
1538
}
1541
1539
1540
+ error :
1542
1541
xmlFree (unescaped );
1542
+ if (encoder != NULL )
1543
+ xmlCharEncCloseFunc (encoder );
1543
1544
return (ret );
1544
1545
}
1545
1546
@@ -1620,7 +1621,10 @@ xmlOutputBufferPtr
1620
1621
xmlOutputBufferCreateFile (FILE * file , xmlCharEncodingHandlerPtr encoder ) {
1621
1622
xmlOutputBufferPtr ret ;
1622
1623
1623
- if (file == NULL ) return (NULL );
1624
+ if (file == NULL ) {
1625
+ xmlCharEncCloseFunc (encoder );
1626
+ return (NULL );
1627
+ }
1624
1628
1625
1629
ret = xmlAllocOutputBuffer (encoder );
1626
1630
if (ret != NULL ) {
@@ -1648,7 +1652,10 @@ xmlOutputBufferCreateBuffer(xmlBufferPtr buffer,
1648
1652
xmlCharEncodingHandlerPtr encoder ) {
1649
1653
xmlOutputBufferPtr ret ;
1650
1654
1651
- if (buffer == NULL ) return (NULL );
1655
+ if (buffer == NULL ) {
1656
+ xmlCharEncCloseFunc (encoder );
1657
+ return (NULL );
1658
+ }
1652
1659
1653
1660
ret = xmlOutputBufferCreateIO (xmlBufferWrite , NULL , (void * ) buffer ,
1654
1661
encoder );
@@ -1913,7 +1920,10 @@ xmlOutputBufferPtr
1913
1920
xmlOutputBufferCreateFd (int fd , xmlCharEncodingHandlerPtr encoder ) {
1914
1921
xmlOutputBufferPtr ret ;
1915
1922
1916
- if (fd < 0 ) return (NULL );
1923
+ if (fd < 0 ) {
1924
+ xmlCharEncCloseFunc (encoder );
1925
+ return (NULL );
1926
+ }
1917
1927
1918
1928
ret = xmlAllocOutputBuffer (encoder );
1919
1929
if (ret != NULL ) {
0 commit comments