[mxml] Workaround mxmlNewTextf/mxmlSaveString segfault

Occurs on amd64 Debian 10.x with mxml 2.12
This commit is contained in:
ejurgensen 2020-04-13 20:59:58 +02:00
parent e6ef106065
commit 5ad5f85cc4
2 changed files with 36 additions and 7 deletions

View File

@ -116,11 +116,18 @@ FORK_MODULES_CHECK([FORKED], [CONFUSE], [libconfuse >= 3.0], [cfg_init], [confus
FORK_MODULES_CHECK([FORKED], [MINIXML], [mxml], FORK_MODULES_CHECK([FORKED], [MINIXML], [mxml],
[mxmlNewElement], [mxml.h], [mxmlNewElement], [mxml.h],
[dnl check for old versions which have a serious memleak [
AC_CHECK_FUNCS([mxmlGetOpaque] [mxmlGetText] [mxmlGetType] [mxmlGetFirstChild]) AC_CHECK_FUNCS([mxmlGetOpaque] [mxmlGetText] [mxmlGetType] [mxmlGetFirstChild])
PKG_CHECK_EXISTS([mxml >= 2.11], [], dnl check for versions 2.10 and earlier which have a serious memleak
[AC_DEFINE([HAVE_MXML_OLD], 1, PKG_CHECK_EXISTS([mxml < 2.11],
[Define to 1 if you have mxml < 2.11)])]) [AC_DEFINE([HAVE_MXML_V211LT], 1,
[Define to 1 if you have mxml < 2.11)])]
)
dnl Debian amd64 mxml 2.12 has a mxmlNewTextf that segfaults
PKG_CHECK_EXISTS([mxml = 2.12],
[AC_DEFINE([HAVE_MXML_V212], 1,
[Define to 1 if you have mxml = 2.12)])]
)
]) ])
FORK_MODULES_CHECK([COMMON], [SQLITE3], [sqlite3 >= 3.5.0], FORK_MODULES_CHECK([COMMON], [SQLITE3], [sqlite3 >= 3.5.0],

View File

@ -5,9 +5,7 @@
// - and since this is the version in Ubuntu 18.04 LTS and Raspian Stretch, we // - and since this is the version in Ubuntu 18.04 LTS and Raspian Stretch, we
// fix it by including a fixed mxmlDelete here. It should be removed once the // fix it by including a fixed mxmlDelete here. It should be removed once the
// major distros no longer have 2.10. The below code is msweet's fixed mxml. // major distros no longer have 2.10. The below code is msweet's fixed mxml.
#ifndef HAVE_MXML_OLD #if defined(HAVE_MXML_211LT)
# include <mxml.h>
#else
// Trick to undefine mxml.h's mxmlDelete // Trick to undefine mxml.h's mxmlDelete
#define mxmlDelete mxmlDelete_memleak #define mxmlDelete mxmlDelete_memleak
# include <mxml.h> # include <mxml.h>
@ -89,6 +87,30 @@ mxmlDelete(mxml_node_t *node)
compat_mxml_free(node); compat_mxml_free(node);
} }
#elif defined(HAVE_MXML_212)
// Trick to undefine mxml.h's mxmlNewTextf
#define mxmlNewTextf mxmlNewTextf_segfault
# include <mxml.h>
#undef mxmlNewTextf
static mxml_node_t *
mxmlNewTextf(mxml_node_t *parent, int whitespace, const char *format, ...)
{
char *s = NULL;
va_list va;
va_start(va, format);
vasprintf(&s, format, va);
va_end(va);
node = mxmlNewText(parent, whitespace, s);
free(s);
return node;
}
#else
# include <mxml.h>
#endif #endif
/* For compability with mxml 2.6 */ /* For compability with mxml 2.6 */