Skip to content

Commit 486fc04

Browse files
committed
Implement github PR #1736
This fixes leak issues on *BSD systems, as described in the PR.
1 parent 80a5ae4 commit 486fc04

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

ext/standard/config.m4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ dnl Detect library functions needed by php dns_xxx functions
401401
dnl ext/standard/php_dns.h will collect these in a single define: HAVE_FULL_DNS_FUNCS
402402
dnl
403403
PHP_CHECK_FUNC(res_nsearch, resolv, bind, socket)
404+
PHP_CHECK_FUNC(res_ndestroy, resolv, bind, socket)
404405
PHP_CHECK_FUNC(dns_search, resolv, bind, socket)
405406
PHP_CHECK_FUNC(dn_expand, resolv, bind, socket)
406407
PHP_CHECK_FUNC(dn_skipname, resolv, bind, socket)

ext/standard/php_dns.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,15 @@
3232
#elif defined(HAVE_RES_NSEARCH)
3333
#define php_dns_search(res, dname, class, type, answer, anslen) \
3434
res_nsearch(res, dname, class, type, answer, anslen);
35+
#if HAVE_RES_NDESTROY
36+
#define php_dns_free_handle(res) \
37+
res_ndestroy(res); \
38+
php_dns_free_res(res)
39+
#else
3540
#define php_dns_free_handle(res) \
3641
res_nclose(res); \
3742
php_dns_free_res(res)
43+
#endif
3844

3945
#elif defined(HAVE_RES_SEARCH)
4046
#define php_dns_search(res, dname, class, type, answer, anslen) \

0 commit comments

Comments
 (0)