mxmlDelete used a recursive algorithm which could require large amounts of

stack space depending on the file (Bug #549)

Bump version to 2.10.
This commit is contained in:
Michael R Sweet 2016-06-11 20:51:49 +00:00
parent 0cc2394ff5
commit d8c0ba9007
4 changed files with 144 additions and 74 deletions

View File

@ -1,6 +1,12 @@
CHANGES - 2014-10-19 CHANGES - 2016-06-11
-------------------- --------------------
CHANGES IN Mini-XML 2.10
- mxmlDelete used a recursive algorithm which could require large
amounts of stack space depending on the file (Bug #549)
CHANGES IN Mini-XML 2.9 CHANGES IN Mini-XML 2.9
- mxmlLoad* did not correctly load value nodes with MXML_NO_CALLBACK - mxmlLoad* did not correctly load value nodes with MXML_NO_CALLBACK

52
configure vendored
View File

@ -1,6 +1,8 @@
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69. # Generated by GNU Autoconf 2.69 for Mini-XML 2.10.
#
# Report bugs to <http://www.msweet.org/bugs.php/Mini-XML>.
# #
# #
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@ -264,8 +266,9 @@ fi
$as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
$as_echo "$0: be upgraded to zsh 4.3.4 or later." $as_echo "$0: be upgraded to zsh 4.3.4 or later."
else else
$as_echo "$0: Please tell bug-autoconf@gnu.org about your system, $as_echo "$0: Please tell bug-autoconf@gnu.org and
$0: including any error possibly output before this $0: http://www.msweet.org/bugs.php/Mini-XML about your
$0: system, including any error possibly output before this
$0: message. Then install a modern shell, or manually run $0: message. Then install a modern shell, or manually run
$0: the script under such a shell if you do have one." $0: the script under such a shell if you do have one."
fi fi
@ -575,14 +578,13 @@ MFLAGS=
MAKEFLAGS= MAKEFLAGS=
# Identity of this package. # Identity of this package.
PACKAGE_NAME= PACKAGE_NAME='Mini-XML'
PACKAGE_TARNAME= PACKAGE_TARNAME='mxml'
PACKAGE_VERSION= PACKAGE_VERSION='2.10'
PACKAGE_STRING= PACKAGE_STRING='Mini-XML 2.10'
PACKAGE_BUGREPORT= PACKAGE_BUGREPORT='http://www.msweet.org/bugs.php/Mini-XML'
PACKAGE_URL= PACKAGE_URL='http://www.msweet.org/projects.php/Mini-XML'
ac_unique_file="mxml.h"
# Factoring default headers for most tests. # Factoring default headers for most tests.
ac_includes_default="\ ac_includes_default="\
#include <stdio.h> #include <stdio.h>
@ -756,7 +758,7 @@ sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var' localstatedir='${prefix}/var'
includedir='${prefix}/include' includedir='${prefix}/include'
oldincludedir='/usr/include' oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE}' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
infodir='${datarootdir}/info' infodir='${datarootdir}/info'
htmldir='${docdir}' htmldir='${docdir}'
dvidir='${docdir}' dvidir='${docdir}'
@ -1256,7 +1258,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures this package to adapt to many kinds of systems. \`configure' configures Mini-XML 2.10 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1304,7 +1306,7 @@ Fine tuning of the installation directories:
--infodir=DIR info documentation [DATAROOTDIR/info] --infodir=DIR info documentation [DATAROOTDIR/info]
--localedir=DIR locale-dependent data [DATAROOTDIR/locale] --localedir=DIR locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man] --mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] --docdir=DIR documentation root [DATAROOTDIR/doc/mxml]
--htmldir=DIR html documentation [DOCDIR] --htmldir=DIR html documentation [DOCDIR]
--dvidir=DIR dvi documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR]
@ -1316,7 +1318,9 @@ _ACEOF
fi fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of Mini-XML 2.10:";;
esac
cat <<\_ACEOF cat <<\_ACEOF
Optional Features: Optional Features:
@ -1350,7 +1354,8 @@ Some influential environment variables:
Use these variables to override the choices made by `configure' or to help Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations. it to find libraries and programs with nonstandard names/locations.
Report bugs to the package provider. Report bugs to <http://www.msweet.org/bugs.php/Mini-XML>.
Mini-XML home page: <http://www.msweet.org/projects.php/Mini-XML>.
_ACEOF _ACEOF
ac_status=$? ac_status=$?
fi fi
@ -1413,7 +1418,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
configure Mini-XML configure 2.10
generated by GNU Autoconf 2.69 generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc. Copyright (C) 2012 Free Software Foundation, Inc.
@ -1723,6 +1728,10 @@ $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
( $as_echo "## ------------------------------------------------------ ##
## Report this to http://www.msweet.org/bugs.php/Mini-XML ##
## ------------------------------------------------------ ##"
) | sed "s/^/$as_me: WARNING: /" >&2
;; ;;
esac esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
@ -1816,7 +1825,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by $as_me, which was It was created by Mini-XML $as_me 2.10, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@ $ $0 $@
@ -2168,7 +2177,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_config_headers="$ac_config_headers config.h" ac_config_headers="$ac_config_headers config.h"
VERSION=2.9 VERSION="2.10"
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
#define MXML_VERSION "Mini-XML v$VERSION" #define MXML_VERSION "Mini-XML v$VERSION"
@ -4965,7 +4974,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" ac_log="
This file was extended by $as_me, which was This file was extended by Mini-XML $as_me 2.10, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
@ -5021,13 +5030,14 @@ $config_files
Configuration headers: Configuration headers:
$config_headers $config_headers
Report bugs to the package provider." Report bugs to <http://www.msweet.org/bugs.php/Mini-XML>.
Mini-XML home page: <http://www.msweet.org/projects.php/Mini-XML>."
_ACEOF _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\ ac_cs_version="\\
config.status Mini-XML config.status 2.10
configured by $0, generated by GNU Autoconf 2.69, configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\" with options \\"\$ac_cs_config\\"

View File

@ -3,7 +3,7 @@ dnl "$Id$"
dnl dnl
dnl Configuration script for Mini-XML, a small XML-like file parsing library. dnl Configuration script for Mini-XML, a small XML-like file parsing library.
dnl dnl
dnl Copyright 2003-2014 by Michael R Sweet. dnl Copyright 2003-2016 by Michael R Sweet.
dnl dnl
dnl These coded instructions, statements, and computer programs are the dnl These coded instructions, statements, and computer programs are the
dnl property of Michael R Sweet and are protected by Federal copyright dnl property of Michael R Sweet and are protected by Federal copyright
@ -14,14 +14,14 @@ dnl
dnl http://www.msweet.org/projects.php/Mini-XML dnl http://www.msweet.org/projects.php/Mini-XML
dnl dnl
dnl Specify a source file from the distribution... dnl Package name and version...
AC_INIT(mxml.h) AC_INIT([Mini-XML], [2.10], [http://www.msweet.org/bugs.php/Mini-XML], [mxml], [http://www.msweet.org/projects.php/Mini-XML])
dnl Set the name of the config header file... dnl Set the name of the config header file...
AC_CONFIG_HEADER(config.h) AC_CONFIG_HEADER(config.h)
dnl Version number... dnl Version number...
VERSION=2.9 VERSION="AC_PACKAGE_VERSION"
AC_SUBST(VERSION) AC_SUBST(VERSION)
AC_DEFINE_UNQUOTED(MXML_VERSION, "Mini-XML v$VERSION") AC_DEFINE_UNQUOTED(MXML_VERSION, "Mini-XML v$VERSION")

View File

@ -3,7 +3,7 @@
* *
* Node support code for Mini-XML, a small XML-like file parsing library. * Node support code for Mini-XML, a small XML-like file parsing library.
* *
* Copyright 2003-2014 by Michael R Sweet. * Copyright 2003-2016 by Michael R Sweet.
* *
* These coded instructions, statements, and computer programs are the * These coded instructions, statements, and computer programs are the
* property of Michael R Sweet and are protected by Federal copyright * property of Michael R Sweet and are protected by Federal copyright
@ -26,6 +26,7 @@
* Local functions... * Local functions...
*/ */
static void mxml_free(mxml_node_t *node);
static mxml_node_t *mxml_new(mxml_node_t *parent, mxml_type_t type); static mxml_node_t *mxml_new(mxml_node_t *parent, mxml_type_t type);
@ -177,7 +178,8 @@ mxmlAdd(mxml_node_t *parent, /* I - Parent node */
void void
mxmlDelete(mxml_node_t *node) /* I - Node to delete */ mxmlDelete(mxml_node_t *node) /* I - Node to delete */
{ {
int i; /* Looping var */ mxml_node_t *current, /* Current node */
*next; /* Next node */
#ifdef DEBUG #ifdef DEBUG
@ -201,60 +203,50 @@ mxmlDelete(mxml_node_t *node) /* I - Node to delete */
* Delete children... * Delete children...
*/ */
while (node->child) for (current = node->child; current; current = next)
mxmlDelete(node->child);
/*
* Now delete any node data...
*/
switch (node->type)
{ {
case MXML_ELEMENT : /*
if (node->value.element.name) * Get the next node...
free(node->value.element.name); */
if (node->value.element.num_attrs) if ((next = current->child) != NULL)
{ {
for (i = 0; i < node->value.element.num_attrs; i ++) /*
{ * Free parent nodes after child nodes have been freed...
if (node->value.element.attrs[i].name) */
free(node->value.element.attrs[i].name);
if (node->value.element.attrs[i].value)
free(node->value.element.attrs[i].value);
}
free(node->value.element.attrs); current->child = NULL;
} continue;
break; }
case MXML_INTEGER :
/* Nothing to do */ if ((next = current->next) == NULL)
break; {
case MXML_OPAQUE : mxml_node_t *temp = current->parent;
if (node->value.opaque) /* Pointer to parent node */
free(node->value.opaque);
break; if (temp == node)
case MXML_REAL : {
/* Nothing to do */ /*
break; * Got back to the top node...
case MXML_TEXT : */
if (node->value.text.string)
free(node->value.text.string); next = NULL;
break; }
case MXML_CUSTOM : else if ((next = temp->next) == NULL)
if (node->value.custom.data && {
node->value.custom.destroy) if ((next = temp->parent) == node)
(*(node->value.custom.destroy))(node->value.custom.data); next = NULL;
break; }
default : }
break;
mxml_free(current);
} }
/* /*
* Free this node... * Then free the memory used by this node...
*/ */
free(node); mxml_free(node);
} }
@ -729,6 +721,68 @@ mxmlRetain(mxml_node_t *node) /* I - Node */
} }
/*
* 'mxml_free()' - Free the memory used by a node.
*
* Note: Does not free child nodes, does not remove from parent.
*/
static void
mxml_free(mxml_node_t *node) /* I - Node */
{
int i; /* Looping var */
switch (node->type)
{
case MXML_ELEMENT :
if (node->value.element.name)
free(node->value.element.name);
if (node->value.element.num_attrs)
{
for (i = 0; i < node->value.element.num_attrs; i ++)
{
if (node->value.element.attrs[i].name)
free(node->value.element.attrs[i].name);
if (node->value.element.attrs[i].value)
free(node->value.element.attrs[i].value);
}
free(node->value.element.attrs);
}
break;
case MXML_INTEGER :
/* Nothing to do */
break;
case MXML_OPAQUE :
if (node->value.opaque)
free(node->value.opaque);
break;
case MXML_REAL :
/* Nothing to do */
break;
case MXML_TEXT :
if (node->value.text.string)
free(node->value.text.string);
break;
case MXML_CUSTOM :
if (node->value.custom.data &&
node->value.custom.destroy)
(*(node->value.custom.destroy))(node->value.custom.data);
break;
default :
break;
}
/*
* Free this node...
*/
free(node);
}
/* /*
* 'mxml_new()' - Create a new node. * 'mxml_new()' - Create a new node.
*/ */