diff --git a/CHANGES b/CHANGES
index f2427b3..ffc649f 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,8 +1,11 @@
-README - 12/02/2003
+README - 12/13/2003
-------------------
CHANGES IN Mini-XML 1.3
+ - mxmlLoadString/File() would crash when loading non-
+ conformant XML data under an existing parent (top)
+ node.
- Fixed several bugs in the mxmldoc utility.
- Added new error callback function to catch a variety
of errors and log them to someplace other than stderr.
diff --git a/mxml-file.c b/mxml-file.c
index 585dbba..a1ae31e 100644
--- a/mxml-file.c
+++ b/mxml-file.c
@@ -1,5 +1,5 @@
/*
- * "$Id: mxml-file.c,v 1.23 2003/12/03 03:59:04 mike Exp $"
+ * "$Id: mxml-file.c,v 1.24 2003/12/13 16:32:42 mike Exp $"
*
* File loading code for mini-XML, a small XML-like file parsing library.
*
@@ -817,7 +817,7 @@ mxml_load_data(mxml_node_t *top, /* I - Top node */
if (parent)
{
- while (parent->parent != top)
+ while (parent->parent != top && parent->parent)
parent = parent->parent;
}
@@ -1661,5 +1661,5 @@ mxml_write_ws(mxml_node_t *node, /* I - Current node */
/*
- * End of "$Id: mxml-file.c,v 1.23 2003/12/03 03:59:04 mike Exp $".
+ * End of "$Id: mxml-file.c,v 1.24 2003/12/13 16:32:42 mike Exp $".
*/
diff --git a/testmxml.c b/testmxml.c
index e8e9dca..60a983f 100644
--- a/testmxml.c
+++ b/testmxml.c
@@ -1,5 +1,5 @@
/*
- * "$Id: testmxml.c,v 1.12 2003/07/27 23:11:40 mike Exp $"
+ * "$Id: testmxml.c,v 1.13 2003/12/13 16:32:42 mike Exp $"
*
* Test program for mini-XML, a small XML-like file parsing library.
*
@@ -47,6 +47,7 @@ int /* O - Exit status */
main(int argc, /* I - Number of command-line args */
char *argv[]) /* I - Command-line args */
{
+ int i; /* Looping var */
FILE *fp; /* File to read */
mxml_node_t *tree, /* XML tree */
*node; /* Node which should be in test.xml */
@@ -105,6 +106,15 @@ main(int argc, /* I - Number of command-line args */
mxmlNewReal(tree, 123.4f);
mxmlNewText(tree, 1, "text");
+ mxmlLoadString(tree, "string string string",
+ MXML_NO_CALLBACK);
+ mxmlLoadString(tree, "1 2 3",
+ MXML_INTEGER_CALLBACK);
+ mxmlLoadString(tree, "1.0 2.0 3.0",
+ MXML_REAL_CALLBACK);
+ mxmlLoadString(tree, "opaque opaque opaque",
+ MXML_OPAQUE_CALLBACK);
+
node = tree->child;
if (!node)
@@ -211,10 +221,39 @@ main(int argc, /* I - Number of command-line args */
return (1);
}
- mxmlDelete(tree->child);
- mxmlDelete(tree->child);
- mxmlDelete(tree->child);
- mxmlDelete(tree->child);
+ for (i = 0; i < 4; i ++)
+ {
+ node = node->next;
+
+ if (!node)
+ {
+ fprintf(stderr, "ERROR: No group #%d child node in basic test!\n", i + 1);
+ mxmlDelete(tree);
+ return (1);
+ }
+
+ if (node->type != MXML_ELEMENT)
+ {
+ fprintf(stderr, "ERROR: Group child #%d has type %s (%d), expected MXML_ELEMENT!\n",
+ i + 1, node->type < MXML_ELEMENT || node->type > MXML_TEXT ?
+ "UNKNOWN" : types[node->type], node->type);
+ mxmlDelete(tree);
+ return (1);
+ }
+ }
+
+ for (i = 0; i < 8; i ++)
+ {
+ if (tree->child)
+ mxmlDelete(tree->child);
+ else
+ {
+ fprintf(stderr, "ERROR: Child pointer prematurely NULL on child #%d\n",
+ i + 1);
+ mxmlDelete(tree);
+ return (1);
+ }
+ }
if (tree->child)
{
@@ -392,5 +431,5 @@ whitespace_cb(mxml_node_t *node, /* I - Element node */
/*
- * End of "$Id: testmxml.c,v 1.12 2003/07/27 23:11:40 mike Exp $".
+ * End of "$Id: testmxml.c,v 1.13 2003/12/13 16:32:42 mike Exp $".
*/