From db78bc0c469cdd59eae11622ba2147fb67fdf459 Mon Sep 17 00:00:00 2001 From: sauwming Date: Tue, 27 Jun 2023 14:07:04 +0800 Subject: [PATCH] Check the return status of pj_getaddrinfo() when creating contact (#3601) --- pjsip/src/pjsua-lib/pjsua_acc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pjsip/src/pjsua-lib/pjsua_acc.c b/pjsip/src/pjsua-lib/pjsua_acc.c index afbbdc284..e485735d8 100644 --- a/pjsip/src/pjsua-lib/pjsua_acc.c +++ b/pjsip/src/pjsua-lib/pjsua_acc.c @@ -3586,7 +3586,9 @@ pj_status_t pjsua_acc_get_uac_addr(pjsua_acc_id acc_id, } ai_cnt = 1; - pj_getaddrinfo(af, &dinfo.addr.host, &ai_cnt, &ai[0]); + status = pj_getaddrinfo(af, &dinfo.addr.host, &ai_cnt, &ai[0]); + if (status != PJ_SUCCESS) + ai_cnt = 0; /* Get fallback address, only if the host is not IP address and * account is not bound to a certain transport. @@ -3607,7 +3609,9 @@ pj_status_t pjsua_acc_get_uac_addr(pjsua_acc_id acc_id, (af == pj_AF_INET6() && acc->cfg.ipv6_sip_use != PJSUA_IPV6_DISABLED)) { - pj_getaddrinfo(af, &dinfo.addr.host, &cnt, &ai[ai_cnt]); + status = pj_getaddrinfo(af, &dinfo.addr.host, &cnt, &ai[ai_cnt]); + if (status != PJ_SUCCESS) + cnt = 0; ai_cnt += cnt; } }