fixed a limit case problem with "<a/>" Daniel
* xmlreader.c python/tests/reader.py: fixed a limit case problem
with "<a/>"
Daniel
diff --git a/ChangeLog b/ChangeLog
index cfe766e..8123da5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Dec 30 12:39:55 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+ * xmlreader.c python/tests/reader.py: fixed a limit case problem
+ with "<a/>"
+
Mon Dec 30 11:53:44 CET 2002 Daniel Veillard <daniel@veillard.com>
* SAX.c: warn on xmlns:prefix="foo"
diff --git a/python/tests/reader.py b/python/tests/reader.py
index 75d6d8d..c874160 100755
--- a/python/tests/reader.py
+++ b/python/tests/reader.py
@@ -301,6 +301,28 @@
print "test7: failed to read the namespace node"
sys.exit(1)
+#
+# Test for a limit case:
+#
+f = StringIO.StringIO("""<a/>""")
+input = libxml2.inputBuffer(f)
+reader = input.newTextReader("test8")
+ret = reader.Read()
+if ret != 1:
+ print "test8: failed to read the node"
+ sys.exit(1)
+if reader.Name() != "a" or reader.IsEmptyElement() != 1:
+ print "test8: failed to analyze the node"
+ sys.exit(1)
+ret = reader.Read()
+if ret != 0:
+ print "test8: failed to detect the EOF"
+ sys.exit(1)
+
+
+#
+# cleanup for memory allocation counting
+#
del f
del input
del reader
diff --git a/xmlreader.c b/xmlreader.c
index 3bca6c8..2b2436d 100644
--- a/xmlreader.c
+++ b/xmlreader.c
@@ -264,7 +264,9 @@
if (val <= 0) {
reader->mode = XML_TEXTREADER_MODE_EOF;
reader->state = oldstate;
- return(val);
+ if ((oldstate != XML_TEXTREADER_START) ||
+ (reader->ctxt->myDoc != NULL))
+ return(val);
}
} else
break;