[mxml] Workaround mxmlNewTextf/mxmlSaveString segfault
Occurs on amd64 Debian 10.x with mxml 2.12
This commit is contained in:
parent
e6ef106065
commit
5ad5f85cc4
15
configure.ac
15
configure.ac
|
@ -116,11 +116,18 @@ FORK_MODULES_CHECK([FORKED], [CONFUSE], [libconfuse >= 3.0], [cfg_init], [confus
|
|||
|
||||
FORK_MODULES_CHECK([FORKED], [MINIXML], [mxml],
|
||||
[mxmlNewElement], [mxml.h],
|
||||
[dnl check for old versions which have a serious memleak
|
||||
[
|
||||
AC_CHECK_FUNCS([mxmlGetOpaque] [mxmlGetText] [mxmlGetType] [mxmlGetFirstChild])
|
||||
PKG_CHECK_EXISTS([mxml >= 2.11], [],
|
||||
[AC_DEFINE([HAVE_MXML_OLD], 1,
|
||||
[Define to 1 if you have mxml < 2.11)])])
|
||||
dnl check for versions 2.10 and earlier which have a serious memleak
|
||||
PKG_CHECK_EXISTS([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],
|
||||
|
|
|
@ -5,9 +5,7 @@
|
|||
// - 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
|
||||
// major distros no longer have 2.10. The below code is msweet's fixed mxml.
|
||||
#ifndef HAVE_MXML_OLD
|
||||
# include <mxml.h>
|
||||
#else
|
||||
#if defined(HAVE_MXML_211LT)
|
||||
// Trick to undefine mxml.h's mxmlDelete
|
||||
#define mxmlDelete mxmlDelete_memleak
|
||||
# include <mxml.h>
|
||||
|
@ -89,6 +87,30 @@ mxmlDelete(mxml_node_t *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
|
||||
|
||||
/* For compability with mxml 2.6 */
|
||||
|
|
Loading…
Reference in New Issue