@@ -634,7 +634,8 @@ static apr_status_t beacon_resolve(apr_pool_t *p, const char *url,
634634 * else the first listener. Either output may remain unset (host NULL / port 0)
635635 * if no listeners are configured.
636636 */
637- static void beacon_server_default_addr (server_rec * s , const char * * host_out ,
637+ static void beacon_server_default_addr (server_rec * s , apr_pool_t * p ,
638+ const char * * host_out ,
638639 apr_port_t * port_out )
639640{
640641 const char * host = NULL ;
@@ -654,12 +655,15 @@ static void beacon_server_default_addr(server_rec *s, const char **host_out,
654655 }
655656 }
656657 if (match && match -> bind_addr ) {
657- char * ip = NULL ;
658+ char ip [ APRMAXHOSTLEN ] ;
658659 if (!port ) {
659660 port = match -> bind_addr -> port ;
660661 }
661- if (apr_sockaddr_ip_get (& ip , match -> bind_addr ) == APR_SUCCESS ) {
662- host = ip ;
662+ /* Not apr_sockaddr_ip_get(): it would allocate from the listener's
663+ * pool, the process pool, which this watchdog thread must not use. */
664+ if (apr_sockaddr_ip_getbuf (ip , sizeof ip , match -> bind_addr )
665+ == APR_SUCCESS ) {
666+ host = apr_pstrdup (p , ip );
663667 }
664668 }
665669
@@ -704,7 +708,7 @@ static void beacon_cb_starting(beacon_ctx_t *ctx)
704708 * is for non-privileged service ports.) */
705709 const char * defhost ;
706710 apr_port_t defport ;
707- beacon_server_default_addr (s , & defhost , & defport );
711+ beacon_server_default_addr (s , ctx -> open_pool , & defhost , & defport );
708712 if ((rv = beacon_resolve (ctx -> open_pool , ctx -> sub_url , defhost , defport ,
709713 & ctx -> addr )) != APR_SUCCESS ) {
710714 ap_log_error (APLOG_MARK , APLOG_ERR , rv , s ,
0 commit comments