[MPlayer-dev-eng] [PATCH] demux_mkv.c: fix crash with gcc 4.4 and optimizations

Corey Hickey bugfood-ml at fatooh.org
Wed Sep 30 10:13:35 CEST 2009


Reimar Döffinger wrote:
> On Tue, Sep 29, 2009 at 05:59:12PM -0700, Corey Hickey wrote:
>> Index: libmpdemux/demux_mkv.c
>> ===================================================================
>> --- libmpdemux/demux_mkv.c	(revision 29731)
>> +++ libmpdemux/demux_mkv.c	(working copy)
>> @@ -203,16 +203,25 @@
>>  extern int dvdsub_id;
>>  
>>  /**
>> - * \brief ensures there is space for at least one additional element
>> + * \brief ensures there is space for at least one additional uint64_t
>>   * \param array array to grow
>>   * \param nelem current number of elements in array
>> - * \param elsize size of one array element
>>   */
>> -static void grow_array(void **array, int nelem, size_t elsize) {
>> +static void grow_array_uint64(uint64_t **array, int nelem) {
>>    if (!(nelem & 31))
>> -    *array = realloc(*array, (nelem + 32) * elsize);
>> +    *array = realloc(*array, (nelem + 32) * sizeof(uint64_t));
>>  }
>>  
>> +/**
>> + * \brief ensures there is space for at least one additional mkv_index_t
>> + * \param array array to grow
>> + * \param nelem current number of elements in array
>> + */
>> +static void grow_array_mkv_index(mkv_index_t **array, int nelem) {
>> +  if (!(nelem & 31))
>> +    *array = realloc(*array, (nelem + 32) * sizeof(mkv_index_t));
>> +}
>> +
> 
> Duplicating the code makes the whole thing rather pointless, the only
> reason for the function was avoiding code duplication.

Yeah, I figured as much...

> In case -Wstrict-aliasing=2 is reliable, this much simpler patch will
> fix it too.

Looks good; I tested it and it seems fine. No warnings, no segfault.

Thank you!

-Corey



More information about the MPlayer-dev-eng mailing list