Changeset 6098


Ignore:
Timestamp:
Oct 30, 2019 5:20:06 AM (4 years ago)
Author:
ming
Message:

Fixed #2248: Memory leak if stream fails to be created

Location:
pjproject/trunk/pjmedia/src/pjmedia
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/stream.c

    r6043 r6098  
    28502850 
    28512851    /* Send RTCP BYE (also SDES & XR) */ 
    2852     if (!stream->rtcp_sdes_bye_disabled) { 
     2852    if (stream->transport && !stream->rtcp_sdes_bye_disabled) { 
    28532853        send_rtcp(stream, PJ_TRUE, PJ_TRUE, PJ_TRUE, PJ_FALSE); 
    28542854    } 
  • pjproject/trunk/pjmedia/src/pjmedia/vid_stream.c

    r6093 r6098  
    16041604                                               &stream->codec); 
    16051605    if (status != PJ_SUCCESS) 
    1606         return status; 
     1606        goto err_cleanup; 
    16071607 
    16081608    /* Get codec param: */ 
     
    16141614                                                         &def_param); 
    16151615        if (status != PJ_SUCCESS) 
    1616             return status; 
     1616            goto err_cleanup; 
    16171617 
    16181618        info->codec_param = pjmedia_vid_codec_param_clone(pool, &def_param); 
     
    16651665    status = pj_mutex_create_simple(pool, NULL, &stream->jb_mutex); 
    16661666    if (status != PJ_SUCCESS) 
    1667         return status; 
     1667        goto err_cleanup; 
    16681668 
    16691669    /* Init and open the codec. */ 
    16701670    status = pjmedia_vid_codec_init(stream->codec, pool); 
    16711671    if (status != PJ_SUCCESS) 
    1672         return status; 
     1672        goto err_cleanup; 
    16731673    status = pjmedia_vid_codec_open(stream->codec, info->codec_param); 
    16741674    if (status != PJ_SUCCESS) 
    1675         return status; 
     1675        goto err_cleanup; 
    16761676 
    16771677    /* Subscribe to codec events */ 
     
    17321732                             info->rx_pt, info, &stream->dec); 
    17331733    if (status != PJ_SUCCESS) 
    1734         return status; 
     1734        goto err_cleanup; 
    17351735 
    17361736    /* Create encoder channel */ 
     
    17381738                             info->tx_pt, info, &stream->enc); 
    17391739    if (status != PJ_SUCCESS) 
    1740         return status; 
     1740        goto err_cleanup; 
    17411741 
    17421742    /* Create temporary buffer for immediate decoding */ 
     
    17971797                                 jb_max, &stream->jb); 
    17981798    if (status != PJ_SUCCESS) 
    1799         return status; 
     1799        goto err_cleanup; 
    18001800 
    18011801 
     
    18471847    status = pjmedia_transport_attach2(tp, &att_param); 
    18481848    if (status != PJ_SUCCESS) 
    1849         return status; 
     1849        goto err_cleanup; 
    18501850 
    18511851    stream->transport = tp; 
     
    19041904 
    19051905    return PJ_SUCCESS; 
     1906 
     1907err_cleanup: 
     1908    pjmedia_vid_stream_destroy(stream); 
     1909    return status; 
    19061910} 
    19071911 
     
    19281932 
    19291933    /* Send RTCP BYE (also SDES) */ 
    1930     if (!stream->rtcp_sdes_bye_disabled) { 
     1934    if (stream->transport && !stream->rtcp_sdes_bye_disabled) { 
    19311935        send_rtcp(stream, PJ_TRUE, PJ_TRUE); 
    19321936    } 
Note: See TracChangeset for help on using the changeset viewer.