Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed msg_data assertion in pjsua_acc_send_request() API #4298

Merged
merged 2 commits into from
Feb 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions pjsip/src/pjsua-lib/pjsua_acc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1556,18 +1556,19 @@ PJ_DEF(pj_status_t) pjsua_acc_send_request(pjsua_acc_id acc_id,
pjsip_tx_data *tdata = NULL;
send_request_data *request_data = NULL;

PJ_ASSERT_RETURN(acc_id>=0, PJ_EINVAL);
PJ_ASSERT_RETURN(acc_id>=0 && acc_id<(int)PJ_ARRAY_SIZE(pjsua_var.acc),
PJ_EINVAL);
PJ_ASSERT_RETURN(pjsua_acc_is_valid(acc_id), PJ_EINVAL);
PJ_ASSERT_RETURN(dest_uri, PJ_EINVAL);
PJ_ASSERT_RETURN(method, PJ_EINVAL);
PJ_UNUSED_ARG(options);
PJ_ASSERT_RETURN(msg_data, PJ_EINVAL);
sauwming marked this conversation as resolved.
Show resolved Hide resolved

PJ_LOG(4,(THIS_FILE, "Account %d sending %.*s request..",
acc_id, (int)method->slen, method->ptr));
pj_log_push_indent();

pjsip_method_init_np(&method_, (pj_str_t*)method);
status = pjsua_acc_create_request(acc_id, &method_, &msg_data->target_uri, &tdata);
status = pjsua_acc_create_request(acc_id, &method_, dest_uri, &tdata);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Unable to create request", status);
goto on_return;
Expand All @@ -1581,7 +1582,8 @@ PJ_DEF(pj_status_t) pjsua_acc_send_request(pjsua_acc_id acc_id,
request_data->acc_id = acc_id;
request_data->token = token;

pjsua_process_msg_data(tdata, msg_data);
if (msg_data)
pjsua_process_msg_data(tdata, msg_data);

cap_hdr = pjsip_endpt_get_capability(pjsua_var.endpt, PJSIP_H_ACCEPT, NULL);
if (cap_hdr) {
Expand Down Expand Up @@ -3433,16 +3435,21 @@ PJ_DEF(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id,
pjsip_tpselector tp_sel;
pj_status_t status;

PJ_ASSERT_RETURN(acc_id>=0 && acc_id<(int)PJ_ARRAY_SIZE(pjsua_var.acc),
PJ_EINVAL);
PJ_ASSERT_RETURN(method && target && p_tdata, PJ_EINVAL);
PJ_ASSERT_RETURN(pjsua_acc_is_valid(acc_id), PJ_EINVAL);

PJSUA_LOCK();

acc = &pjsua_var.acc[acc_id];

status = pjsip_endpt_create_request(pjsua_var.endpt, method, target,
&acc->cfg.id, target,
NULL, NULL, -1, NULL, &tdata);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Unable to create request", status);
PJSUA_UNLOCK();
return status;
}

Expand Down Expand Up @@ -3477,6 +3484,8 @@ PJ_DEF(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id,
&tdata->via_tp);
}

PJSUA_UNLOCK();

/* Done */
*p_tdata = tdata;
return PJ_SUCCESS;
Expand Down
Loading