Changeset 2811


Ignore:
Timestamp:
Jun 25, 2009 1:01:06 PM (11 years ago)
Author:
bennylp
Message:

Ticket #787: Crash when UAC invite or subscribe session initialization fails (thanks Rostislav Molodyko for the report)

  • backported changes from #786
Location:
pjproject/branches/1.0/pjsip/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/1.0/pjsip/src/pjsip-ua/sip_inv.c

    r2803 r2811  
    13681368 
    13691369        status = pjmedia_sdp_neg_get_neg_local(inv->neg, &offer); 
    1370         if (status != PJ_SUCCESS) 
     1370        if (status != PJ_SUCCESS) { 
     1371            pjsip_tx_data_dec_ref(tdata); 
    13711372            goto on_return; 
     1373        } 
    13721374 
    13731375        tdata->msg->body = create_sdp_body(tdata->pool, offer); 
  • pjproject/branches/1.0/pjsip/src/pjsua-lib/pjsua_call.c

    r2802 r2811  
    449449    } 
    450450 
     451    /* Increment the dialog's lock otherwise when invite session creation 
     452     * fails the dialog will be destroyed prematurely. 
     453     */ 
     454    pjsip_dlg_inc_lock(dlg); 
     455 
    451456    /* Calculate call's secure level */ 
    452457    call->secure_level = get_secure_level(acc_id, dest_uri); 
     
    539544                     status); 
    540545 
    541         /* Upon failure to send first request, both dialog and invite  
     546        /* Upon failure to send first request, the invite  
    542547         * session would have been cleared. 
    543548         */ 
    544549        inv = NULL; 
    545         dlg = NULL; 
    546550        goto on_error; 
    547551    } 
     
    552556        *p_call_id = call_id; 
    553557 
     558    pjsip_dlg_dec_lock(dlg); 
    554559    pj_pool_release(tmp_pool); 
    555560    PJSUA_UNLOCK(); 
     
    559564 
    560565on_error: 
     566    if (dlg) { 
     567        /* This may destroy the dialog */ 
     568        pjsip_dlg_dec_lock(dlg); 
     569    } 
     570 
    561571    if (inv != NULL) { 
    562572        pjsip_inv_terminate(inv, PJSIP_SC_OK, PJ_FALSE); 
    563     } else if (dlg) { 
    564         pjsip_dlg_terminate(dlg); 
    565573    } 
    566574 
  • pjproject/branches/1.0/pjsip/src/pjsua-lib/pjsua_pres.c

    r2394 r2811  
    14431443    } 
    14441444 
     1445    /* Increment the dialog's lock otherwise when presence session creation 
     1446     * fails the dialog will be destroyed prematurely. 
     1447     */ 
     1448    pjsip_dlg_inc_lock(buddy->dlg); 
     1449 
    14451450    status = pjsip_pres_create_uac( buddy->dlg, &pres_callback,  
    14461451                                    PJSIP_EVSUB_NO_EVENT_ID, &buddy->sub); 
     
    14491454        pjsua_perror(THIS_FILE, "Unable to create presence client",  
    14501455                     status); 
    1451         pjsip_dlg_terminate(buddy->dlg); 
     1456        /* This should destroy the dialog since there's no session 
     1457         * referencing it 
     1458         */ 
     1459        pjsip_dlg_dec_lock(buddy->dlg); 
    14521460        if (tmp_pool) pj_pool_release(tmp_pool); 
    14531461        return; 
     
    14821490    status = pjsip_pres_initiate(buddy->sub, -1, &tdata); 
    14831491    if (status != PJ_SUCCESS) { 
     1492        pjsip_dlg_dec_lock(buddy->dlg); 
    14841493        if (buddy->sub) { 
    14851494            pjsip_pres_terminate(buddy->sub, PJ_FALSE); 
     
    14961505    status = pjsip_pres_send_request(buddy->sub, tdata); 
    14971506    if (status != PJ_SUCCESS) { 
     1507        pjsip_dlg_dec_lock(buddy->dlg); 
    14981508        if (buddy->sub) { 
    14991509            pjsip_pres_terminate(buddy->sub, PJ_FALSE); 
     
    15061516    } 
    15071517 
     1518    pjsip_dlg_dec_lock(buddy->dlg); 
    15081519    if (tmp_pool) pj_pool_release(tmp_pool); 
    15091520} 
Note: See TracChangeset for help on using the changeset viewer.