[FFmpeg-trac] #6403(avformat:new): Use of both posix_memalign() and realloc() on same memory block not supported

FFmpeg trac at avcodec.org
Fri May 19 01:21:41 EEST 2017

#6403: Use of both posix_memalign() and realloc() on same memory block not
             Reporter:  jrummell  |                     Type:  defect
               Status:  new       |                 Priority:  normal
            Component:  avformat  |                  Version:  unspecified
             Keywords:            |               Blocked By:
             Blocking:            |  Reproduced by developer:  0
Analyzed by developer:  0         |
 Attempting to update Chromium to use the latest FFmpeg, I get the
 following when running some of the tests:

 realloc/memalign mismatch at 0x63cf52e67c0: non-NULL pointers passed to
 realloc must be obtained from malloc, calloc, or realloc

 This is processing an H264 file (repro case for https://crbug.com/444539).

 Chromium uses posix_memalign() for av_malloc().

 It turns out that the code in libavformat/mov.c uses both av_malloc() and
 av_realloc() on AVCodecParameters.extradata. This appears to be
 incompatible if

 Allocations of extradata in
 line 1428 in mov_realloc_extradata() uses av_reallocp().
 line 1650 in mov_read_wave() uses av_mallocz().
 line 2073 in mov_rewrite_dvd_sub_extradata() uses av_mallocz().
 line 2333 in ff_mov_read_stsd_entries() uses av_malloc().

 I also noticed that ff_alloc_extradata() in utils.c uses av_malloc().

 So it looks like mov_realloc_extradata() should have a special case for
 HAVE_POSIX_MEMALIGN that implements realloc locally.

 (And possibly cleanup the other calls in mov.c to use

Ticket URL: <https://trac.ffmpeg.org/ticket/6403>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker

More information about the FFmpeg-trac mailing list