diff -Naur expat-2.0.1.orig/lib/xmlparse.c expat-2.0.1/lib/xmlparse.c --- expat-2.0.1.orig/lib/xmlparse.c 2007-05-07 23:25:35.000000000 -0300 +++ expat-2.0.1/lib/xmlparse.c 2009-08-26 16:50:55.000000000 -0300 @@ -2563,6 +2563,8 @@ (int)(dataPtr - (ICHAR *)dataBuf)); if (s == next) break; + if (ps_parsing == XML_FINISHED || ps_parsing == XML_SUSPENDED) + break; *eventPP = s; } } diff -Naur expat-2.0.1.orig/lib/xmltok_impl.c expat-2.0.1/lib/xmltok_impl.c --- expat-2.0.1.orig/lib/xmltok_impl.c 2006-11-26 15:34:46.000000000 -0200 +++ expat-2.0.1/lib/xmltok_impl.c 2009-08-26 16:50:57.000000000 -0300 @@ -1744,7 +1744,7 @@ const char *end, POSITION *pos) { - while (ptr != end) { + while (ptr < end) { switch (BYTE_TYPE(enc, ptr)) { #define LEAD_CASE(n) \ case BT_LEAD ## n: \