summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTomas Gonzalez <tomas@fuel7.com>2021-11-01 10:01:06 -0700
committerTomas Gonzalez <tomas@fuel7.com>2021-11-04 15:46:59 -0700
commit9a38bc5f73823ac72d6c6b74de7b3ac592a8c7f2 (patch)
tree1e0b099d0568e5b78c7274fd0ac73c7751884514 /test
parent3daebf308a01b4b2d3fb867be3d6631f7b5a2dbb (diff)
downloadlibevent-9a38bc5f73823ac72d6c6b74de7b3ac592a8c7f2.tar.gz
evutil: Fix evutil_freeaddrinfo
During testing on win32, util/getaddrinfo failed with NULL hint info r = evutil_getaddrinfo("www.google.com", NULL, NULL, &ai); throwing a critical heap exception when evutil_freeaddrinfo is called. This is because of improper use of freeaddrinfo when nodes within the ai structure are allocated using mm_malloc or mm_calloc (EVUTIL_AI_LIBEVENT_ALLOCATED) This adds the flag in apply_socktype_protocol_hack and walks the linked list in evutil_freeaddrinfo removing linked list nodes that are custom allocated before calling freeaddrinfo.
Diffstat (limited to 'test')
-rw-r--r--test/regress_util.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/regress_util.c b/test/regress_util.c
index 02cf5e19..1f919fe8 100644
--- a/test/regress_util.c
+++ b/test/regress_util.c
@@ -1005,6 +1005,15 @@ test_evutil_getaddrinfo(void *arg)
struct evutil_addrinfo hints;
int r;
+ /* Try NULL hint (win32 bug) */
+ hints.ai_family = PF_UNSPEC;
+ hints.ai_socktype = SOCK_STREAM;
+ r = evutil_getaddrinfo("www.google.com", NULL, NULL, &ai);
+ tt_int_op(r, ==, 0);
+ tt_assert(ai);
+ evutil_freeaddrinfo(ai);
+ ai = NULL;
+
/* Try using it as a pton. */
memset(&hints, 0, sizeof(hints));
hints.ai_family = PF_UNSPEC;