[MPlayer-dev-eng] [PATCH] Movie fragments support for demux_mov

David Romacho romaxin2002 at yahoo.com.au
Sun Jan 6 12:27:39 CET 2008


Reimar Döffinger wrote:
>> +    // Add chunks
>> +    trak->chunks = realloc_struct(trak->chunks, trak->chunks_size+traf->chunks_size, sizeof(mov_chunk_t));
>> +    memcpy( &trak->chunks[trak->chunks_size], traf->chunks, traf->chunks_size*sizeof( mov_chunk_t ) );
>> +    trak->chunks_size += traf->chunks_size;
>>     
>
> Hm.. I think this code may need an integer overflow check for the
> trak->chunks_size+traf->chunks_size and possibly a != NULL check for the
> trak->chunks after realloc to be safe...
> Possibly there is no problem since the values are limited in size so no
> overflow can happen, in this case a comment would probably be good.
>
>   
How can I check an integer overflow, would that be enough:

if((trak->chunks_size+traf->chunks_size < trak->chunk_size)||(trak->chunks_size+traf->chunks_size < traf->chunk_size)) // overflow occured


Is there any nicer way to do that?

  David



More information about the MPlayer-dev-eng mailing list