summaryrefslogtreecommitdiff
path: root/xmlIO.c
diff options
context:
space:
mode:
Diffstat (limited to 'xmlIO.c')
-rw-r--r--xmlIO.c44
1 files changed, 33 insertions, 11 deletions
diff --git a/xmlIO.c b/xmlIO.c
index a51bf64..13a57e7 100644
--- a/xmlIO.c
+++ b/xmlIO.c
@@ -182,7 +182,7 @@ static const char *IOerr[] = {
"loading error",
"not a socket", /* ENOTSOCK */
"already connected", /* EISCONN */
- "connection refuxed", /* ECONNREFUSED */
+ "connection refused", /* ECONNREFUSED */
"unreachable network", /* ENETUNREACH */
"adddress in use", /* EADDRINUSE */
"already in use", /* EALREADY */
@@ -476,7 +476,7 @@ xmlCleanupInputCallbacks(void)
}
/**
- * xmlPopInputCallback:
+ * xmlPopInputCallbacks:
*
* Clear the top input callback from the input stack. this includes the
* compiled-in I/O.
@@ -2180,6 +2180,9 @@ __xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) {
}
#endif
}
+ else
+ xmlInputCallbackTable[i].closecallback (context);
+
return(ret);
}
@@ -2449,6 +2452,7 @@ xmlParserInputBufferCreateFd(int fd, xmlCharEncoding enc) {
xmlParserInputBufferPtr
xmlParserInputBufferCreateMem(const char *mem, int size, xmlCharEncoding enc) {
xmlParserInputBufferPtr ret;
+ int errcode;
if (size <= 0) return(NULL);
if (mem == NULL) return(NULL);
@@ -2458,7 +2462,11 @@ xmlParserInputBufferCreateMem(const char *mem, int size, xmlCharEncoding enc) {
ret->context = (void *) mem;
ret->readcallback = (xmlInputReadCallback) xmlNop;
ret->closecallback = NULL;
- xmlBufferAdd(ret->buffer, (const xmlChar *) mem, size);
+ errcode = xmlBufferAdd(ret->buffer, (const xmlChar *) mem, size);
+ if (errcode != 0) {
+ xmlFree(ret);
+ return(NULL);
+ }
}
return(ret);
@@ -2656,6 +2664,7 @@ int
xmlParserInputBufferPush(xmlParserInputBufferPtr in,
int len, const char *buf) {
int nbchars = 0;
+ int ret;
if (len < 0) return(0);
if ((in == NULL) || (in->error)) return(-1);
@@ -2668,7 +2677,9 @@ xmlParserInputBufferPush(xmlParserInputBufferPtr in,
if (in->raw == NULL) {
in->raw = xmlBufferCreate();
}
- xmlBufferAdd(in->raw, (const xmlChar *) buf, len);
+ ret = xmlBufferAdd(in->raw, (const xmlChar *) buf, len);
+ if (ret != 0)
+ return(-1);
/*
* convert as much as possible to the parser reading buffer.
@@ -2683,7 +2694,9 @@ xmlParserInputBufferPush(xmlParserInputBufferPtr in,
in->rawconsumed += (use - in->raw->use);
} else {
nbchars = len;
- xmlBufferAdd(in->buffer, (xmlChar *) buf, nbchars);
+ ret = xmlBufferAdd(in->buffer, (xmlChar *) buf, nbchars);
+ if (ret != 0)
+ return(-1);
}
#ifdef DEBUG_INPUT
xmlGenericError(xmlGenericErrorContext,
@@ -2737,7 +2750,7 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) {
if (buffree <= 0) {
xmlIOErr(XML_IO_BUFFER_FULL, NULL);
in->error = XML_IO_BUFFER_FULL;
- return(0);
+ return(-1);
}
needSize = in->buffer->use + len + 1;
@@ -2745,7 +2758,7 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) {
if (!xmlBufferResize(in->buffer, needSize)){
xmlIOErrMemory("growing input buffer");
in->error = XML_ERR_NO_MEMORY;
- return(0);
+ return(-1);
}
}
buffer = (char *)&in->buffer->content[in->buffer->use];
@@ -2775,7 +2788,9 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) {
if (in->raw == NULL) {
in->raw = xmlBufferCreate();
}
- xmlBufferAdd(in->raw, (const xmlChar *) buffer, len);
+ res = xmlBufferAdd(in->raw, (const xmlChar *) buffer, len);
+ if (res != 0)
+ return(-1);
/*
* convert as much as possible to the parser reading buffer.
@@ -2866,7 +2881,9 @@ xmlOutputBufferWrite(xmlOutputBufferPtr out, int len, const char *buf) {
if (out->conv == NULL) {
out->conv = xmlBufferCreate();
}
- xmlBufferAdd(out->buffer, (const xmlChar *) buf, chunk);
+ ret = xmlBufferAdd(out->buffer, (const xmlChar *) buf, chunk);
+ if (ret != 0)
+ return(-1);
if ((out->buffer->use < MINLEN) && (chunk == len))
goto done;
@@ -2882,7 +2899,9 @@ xmlOutputBufferWrite(xmlOutputBufferPtr out, int len, const char *buf) {
}
nbchars = out->conv->use;
} else {
- xmlBufferAdd(out->buffer, (const xmlChar *) buf, chunk);
+ ret = xmlBufferAdd(out->buffer, (const xmlChar *) buf, chunk);
+ if (ret != 0)
+ return(-1);
nbchars = out->buffer->use;
}
buf += chunk;
@@ -3005,6 +3024,7 @@ xmlOutputBufferWriteEscape(xmlOutputBufferPtr out, const xmlChar *str,
int nbchars = 0; /* number of chars to output to I/O */
int ret; /* return from function call */
int written = 0; /* number of char written to I/O so far */
+ int oldwritten=0;/* loop guard */
int chunk; /* number of byte currently processed from str */
int len; /* number of bytes in str */
int cons; /* byte from str consumed */
@@ -3016,6 +3036,8 @@ xmlOutputBufferWriteEscape(xmlOutputBufferPtr out, const xmlChar *str,
if (escaping == NULL) escaping = xmlEscapeContent;
do {
+ oldwritten = written;
+
/*
* how many bytes to consume and how many bytes to store.
*/
@@ -3092,7 +3114,7 @@ xmlOutputBufferWriteEscape(xmlOutputBufferPtr out, const xmlChar *str,
xmlBufferResize(out->buffer, out->buffer->size + MINLEN);
}
written += nbchars;
- } while (len > 0);
+ } while ((len > 0) && (oldwritten != written));
done:
#ifdef DEBUG_INPUT