Changeset 2593 for pjproject


Ignore:
Timestamp:
Apr 14, 2009 11:10:31 AM (16 years ago)
Author:
bennylp
Message:

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

Location:
pjproject/trunk/pjsip/src/pjsua-lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c

    r2506 r2593  
    468468    } 
    469469 
     470    /* Increment the dialog's lock otherwise when invite session creation 
     471     * fails the dialog will be destroyed prematurely. 
     472     */ 
     473    pjsip_dlg_inc_lock(dlg); 
     474 
    470475    /* Calculate call's secure level */ 
    471476    call->secure_level = get_secure_level(acc_id, dest_uri); 
     
    558563                     status); 
    559564 
    560         /* Upon failure to send first request, both dialog and invite  
     565        /* Upon failure to send first request, the invite  
    561566         * session would have been cleared. 
    562567         */ 
    563568        inv = NULL; 
    564         dlg = NULL; 
    565569        goto on_error; 
    566570    } 
     
    571575        *p_call_id = call_id; 
    572576 
     577    pjsip_dlg_dec_lock(dlg); 
    573578    pj_pool_release(tmp_pool); 
    574579    PJSUA_UNLOCK(); 
     
    578583 
    579584on_error: 
     585    if (dlg) { 
     586        /* This may destroy the dialog */ 
     587        pjsip_dlg_dec_lock(dlg); 
     588    } 
     589 
    580590    if (inv != NULL) { 
    581591        pjsip_inv_terminate(inv, PJSIP_SC_OK, PJ_FALSE); 
    582     } else if (dlg) { 
    583         pjsip_dlg_terminate(dlg); 
    584592    } 
    585593 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_pres.c

    r2394 r2593  
    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.