[xml] Memory parser bug

Date view Thread view Subject view Author view

From: kavoos (kavoos@issn.org)
Date: Mon Apr 17 2000 - 10:33:09 EDT


Hi !

I have found a little bug when using xmlParseMemory() whith a
UTF-16 document, this patch correct the probleme ...

--- ../old/libxml2-2.0.0/parser.c Wed Apr 12 15:50:22 2000
+++ parser.c Mon Apr 17 16:17:25 2000
@@ -2317,7 +2317,7 @@
                    if ((enc == XML_CHAR_ENCODING_UTF16BE) &&
                        (ctxt->input->cur[0] == 0xFE) &&
                        (ctxt->input->cur[1] == 0xFF)) {
- SKIP(2);
+ SKIP(2);
                    }

                    /*
@@ -2400,8 +2400,13 @@
                                 "xmlSwitchEncoding : out of memory\n");
                        return;
                    }
+ if ( (ctxt->input->cur[0]==0xFE &&
ctxt->input->cur[1]==0xFF) || (ctxt->input->cur[0]==0xFF &&
ctxt->input->cur[1]==0xFE))
+ res = handler->input(buf, ctxt->input->length * 4,
+ &ctxt->input->cur[2], &len);
+ else
                    res = handler->input(buf, ctxt->input->length * 4,
                                         ctxt->input->cur, &len);
+
                    if ((res < 0) ||
                        (len != ctxt->input->length - processed)) {
                        if ((ctxt->sax != NULL) && (ctxt->sax->error !=
NULL))
@@ -2416,8 +2421,10 @@
                    if ((ctxt->input->free != NULL) &&
                        (ctxt->input->base != NULL))
                        ctxt->input->free((xmlChar *)
ctxt->input->base);
- ctxt->input->base = ctxt->input->cur = buf;
- ctxt->input->length = res;
+
+ ctxt->input->base = ctxt->input->cur = buf;
+ ctxt->input->length = res;
+
                }
            }
        } else {
@@ -2442,17 +2449,9 @@
            /* default encoding, no conversion should be needed */
             return;
         case XML_CHAR_ENCODING_UTF16LE:
- ctxt->errNo = XML_ERR_UNSUPPORTED_ENCODING;
- if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
- ctxt->sax->error(ctxt->userData,
- "char encoding UTF16 little endian not supported\n");
- break;
+ return;
         case XML_CHAR_ENCODING_UTF16BE:
- ctxt->errNo = XML_ERR_UNSUPPORTED_ENCODING;
- if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
- ctxt->sax->error(ctxt->userData,
- "char encoding UTF16 big endian not supported\n");
- break;
+ return;
         case XML_CHAR_ENCODING_UCS4LE:
            ctxt->errNo = XML_ERR_UNSUPPORTED_ENCODING;
            if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
@@ -10406,7 +10405,7 @@
     input->base = BAD_CAST buffer;
     input->cur = BAD_CAST buffer;
     input->free = NULL;
-
+ input->length=size;
     inputPush(ctxt, input);
     return(ctxt);
 }

----
Message from the list xml@xmlsoft.org
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@xmlsoft.org


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Wed Aug 02 2000 - 12:30:11 EDT