Changeset 1d6c495f3dc79356f5671625f04c183a904ef71f

Show
Ignore:
Timestamp:
09/16/07 10:24:58 (1 year ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1189931098 +0000
git-parent:

[feadfb1e87e87c918358543aaee59760432f6350]

git-author:
Rémi Denis-Courmont <rem@videolan.org> 1189931098 +0000
Message:

Error handling

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/mux/mpjpeg.c

    r7dd2f15 r1d6c495  
    8080static int Open( vlc_object_t *p_this ) 
    8181{ 
    82     int i_size; 
    8382    sout_mux_t *p_mux = (sout_mux_t*)p_this; 
    8483    sout_mux_sys_t  *p_sys; 
     
    8685 
    8786    msg_Dbg( p_mux, "Multipart jpeg muxer opened" ); 
    88     config_ChainParse( p_mux, SOUT_CFG_PREFIX, ppsz_sout_options, p_mux->p_cfg ); 
     87    psz_separator = var_GetNonEmptyString( p_mux, SOUT_CFG_PREFIX"separator" ); 
     88    if( psz_separator == NULL ) 
     89    { 
     90        msg_Err( p_this, "missing required multipart separator" ); 
     91        return VLC_EGENERIC; 
     92    } 
     93 
     94    config_ChainParse( p_mux, SOUT_CFG_PREFIX, ppsz_sout_options, 
     95                       p_mux->p_cfg ); 
    8996 
    9097    p_sys = p_mux->p_sys = malloc( sizeof(sout_mux_sys_t) ); 
     98    if( p_sys == NULL ) 
     99        return VLC_ENOMEM; 
    91100    p_sys->b_send_headers = VLC_TRUE; 
    92101 
    93     psz_separator = var_GetString( p_mux, SOUT_CFG_PREFIX "separator" ); 
    94     i_size = strlen( psz_separator ) + 2 + 2 + 2 + strlen( CONTENT_TYPE ); 
    95     psz_separator_block = (char*)malloc( i_size ); 
    96     sprintf( psz_separator_block, "\r\n%s\r\n%s\r\n", psz_separator, 
    97                                   CONTENT_TYPE ); 
    98     p_sys->p_separator = block_New( p_mux, i_size ); 
    99     memcpy( p_sys->p_separator->p_buffer, psz_separator_block , i_size ); 
    100  
    101     if( psz_separator_block ) free( psz_separator_block ); 
     102    if( asprintf( &psz_separator_block, "\r\n%s\r\n%s\r\n", psz_separator, 
     103                  CONTENT_TYPE ) == -1 ) 
     104        psz_separator_block = NULL; 
     105    free( psz_separator_block ); 
     106 
     107    if( psz_separator_block == NULL ) 
     108    { 
     109        free( p_sys ); 
     110        return VLC_ENOMEM; 
     111    } 
     112 
     113    p_sys->p_separator = block_New( p_mux, strlen( psz_separator_block ) ); 
     114    strcpy( (char *)p_sys->p_separator->p_buffer, psz_separator_block ); 
    102115 
    103116    p_mux->pf_control   = Control;