fix macro define for freeaddrinfo with asyncns
authorpsykose <alice@ayaya.dev>
Thu, 21 Apr 2022 20:23:32 +0200
changeset 744 4ebe32453682
parent 743 9098ee1972df
child 745 7785b42dd7bc
fix macro define for freeaddrinfo with asyncns previously, this define was only made in lm-asyncns-resolver.c, which does not propagate it to lm-resolver.c, where freeaddrinfo() is used. this means that when asyncns support is used, the standard libc freeaddrinfo() is called on an addrinfo acquired from asyncns_getaddrinfo, which is undefined behaviour, and leads to a segfault on musl libc.
loudmouth/lm-asyncns-resolver.c
loudmouth/lm-asyncns-resolver.h
--- a/loudmouth/lm-asyncns-resolver.c	Sat Jul 10 09:37:34 2021 +0200
+++ b/loudmouth/lm-asyncns-resolver.c	Thu Apr 21 20:23:32 2022 +0200
@@ -21,7 +21,6 @@
 #include <string.h>
 #ifdef HAVE_ASYNCNS
 #include <asyncns.h>
-#define freeaddrinfo(x) asyncns_freeaddrinfo(x)
 
 /* Needed on Mac OS X */
 #if HAVE_ARPA_NAMESER_COMPAT_H
--- a/loudmouth/lm-asyncns-resolver.h	Sat Jul 10 09:37:34 2021 +0200
+++ b/loudmouth/lm-asyncns-resolver.h	Thu Apr 21 20:23:32 2022 +0200
@@ -19,8 +19,14 @@
 #ifndef __LM_ASYNCNS_RESOLVER_H__
 #define __LM_ASYNCNS_RESOLVER_H__
 
+#include <config.h>
+
 #include <glib-object.h>
 
+#ifdef HAVE_ASYNCNS
+#define freeaddrinfo(x) asyncns_freeaddrinfo(x)
+#endif
+
 #include "lm-resolver.h"
 
 G_BEGIN_DECLS