moved serialization of attribute text data (xmlSerializeContent) into a
* tree.c, include/libxml/tree.h: moved serialization of
attribute text data (xmlSerializeContent) into a separate
routine (xmlSerializeTxtContent) so it can be used by xmlwriter.c
* xmlwriter.c: changed handling of attribute string to use the
routine above (fixed bug 131548)
diff --git a/xmlwriter.c b/xmlwriter.c
index 3cda897..c6df6f2 100644
--- a/xmlwriter.c
+++ b/xmlwriter.c
@@ -1175,11 +1175,11 @@
int
xmlTextWriterWriteString(xmlTextWriterPtr writer, const xmlChar * content)
{
- int count;
+ int count=0;
int sum;
xmlLinkPtr lk;
xmlTextWriterStackEntry *p;
- xmlChar *buf = NULL;
+ xmlChar *buf=NULL;
if (writer == NULL)
return -1;
@@ -1212,10 +1212,15 @@
/* fallthrough */
case XML_TEXTWRITER_PI_TEXT:
case XML_TEXTWRITER_TEXT:
- case XML_TEXTWRITER_ATTRIBUTE:
encode:
buf = xmlEncodeSpecialChars(NULL, content);
+ if (buf == NULL)
+ count = -1;
break;
+ case XML_TEXTWRITER_ATTRIBUTE:
+ xmlAttrSerializeTxtContent(writer->out->buffer, NULL,
+ NULL, content);
+ break;
case XML_TEXTWRITER_DTD:
count = xmlOutputBufferWriteString(writer->out, " [");
if (count < 0)
@@ -1227,6 +1232,8 @@
case XML_TEXTWRITER_DTD_ELEM:
case XML_TEXTWRITER_CDATA:
buf = xmlStrdup(content);
+ if (buf == NULL)
+ count = -1;
break;
default:
break;
@@ -1239,8 +1246,7 @@
count =
xmlOutputBufferWriteString(writer->out, (const char *) buf);
xmlFree(buf);
- } else
- count = -1;
+ }
if (count < 0)
return -1;
sum += count;