Changeset e8d41dd3a713bd54aa9251cc87c80747a6e7dfdf

Show
Ignore:
Timestamp:
06/28/08 23:33:08 (2 months ago)
Author:
Rémi Duraffort <ivoire@videolan.org>
git-committer:
Rémi Duraffort <ivoire@videolan.org> 1214688788 +0200
git-parent:

[c8e9ec9612c5421b1299355dfcd20516fab58ba3]

git-author:
Rémi Duraffort <ivoire@videolan.org> 1214688783 +0200
Message:

Check malloc return value.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/codec/avcodec/video.c

    rdb4d130 re8d41dd  
    372372    p_sys->i_buffer_orig = 1; 
    373373    p_sys->p_buffer_orig = p_sys->p_buffer = malloc( p_sys->i_buffer_orig ); 
     374    if( !p_sys->p_buffer_orig ) 
     375    { 
     376        free( p_sys ); 
     377        return VLC_ENOMEM; 
     378    } 
    374379 
    375380    /* Set output properties */ 
     
    529534        p_sys->p_buffer = p_sys->p_buffer_orig; 
    530535        p_sys->i_buffer = p_block->i_buffer; 
     536        if( !p_sys->p_buffer ) 
     537        { 
     538            block_Release( p_block ); 
     539            return NULL; 
     540        } 
    531541        vlc_memcpy( p_sys->p_buffer, p_block->p_buffer, p_block->i_buffer ); 
    532542        memset( p_sys->p_buffer + p_block->i_buffer, 0, 
     
    726736        p = p_sys->p_context->extradata  = 
    727737            malloc( p_sys->p_context->extradata_size ); 
     738        if( !p ) 
     739            return; 
    728740 
    729741        memcpy( &p[0],  "SVQ3", 4 ); 
     
    764776            p_sys->p_context->extradata_size = 8; 
    765777            p_sys->p_context->extradata = malloc( 8 ); 
    766  
    767             memcpy( p_sys->p_context->extradata, 
    768                     p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra ); 
    769             p_sys->p_context->sub_id= ((uint32_t*)p_dec->fmt_in.p_extra)[1]; 
    770  
    771             msg_Warn( p_dec, "using extra data for RV codec sub_id=%08x", 
    772                       p_sys->p_context->sub_id ); 
     778            if( p_sys->p_context->extradata ) 
     779            { 
     780                memcpy( p_sys->p_context->extradata, 
     781                        p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra ); 
     782                p_sys->p_context->sub_id = ((uint32_t*)p_dec->fmt_in.p_extra)[1]; 
     783 
     784                msg_Warn( p_dec, "using extra data for RV codec sub_id=%08x", 
     785                          p_sys->p_context->sub_id ); 
     786            } 
    773787        } 
    774788    } 
     
    778792        p_sys->p_context->extradata = 
    779793            malloc( i_size + FF_INPUT_BUFFER_PADDING_SIZE ); 
    780         memcpy( p_sys->p_context->extradata, 
    781                 p_dec->fmt_in.p_extra, i_size ); 
    782         memset( &((uint8_t*)p_sys->p_context->extradata)[i_size], 
    783                 0, FF_INPUT_BUFFER_PADDING_SIZE ); 
     794        if( p_sys->p_context->extradata ) 
     795        { 
     796            memcpy( p_sys->p_context->extradata, 
     797                    p_dec->fmt_in.p_extra, i_size ); 
     798            memset( &((uint8_t*)p_sys->p_context->extradata)[i_size], 
     799                    0, FF_INPUT_BUFFER_PADDING_SIZE ); 
     800        } 
    784801    } 
    785802}