[FFmpeg-trac] #11620(avutil:new): av_malloc_array(): nmemb and size arguments transposed

FFmpeg trac at avcodec.org
Tue Jun 3 12:36:27 EEST 2025


#11620: av_malloc_array(): nmemb and size arguments transposed
-----------------------------------+--------------------------------------
             Reporter:  francoisk  |                     Type:  defect
               Status:  new        |                 Priority:  normal
            Component:  avutil     |                  Version:  git-master
             Keywords:  memory     |               Blocked By:
             Blocking:             |  Reproduced by developer:  0
Analyzed by developer:  0          |
-----------------------------------+--------------------------------------
 At line 356 of `libavutil/frame.c` is the following call to
 `av_malloc_array`:


 {{{
 dst->extended_data = av_malloc_array(sizeof(*dst->extended_data), ch);
 }}}


 Looks like the arguments are the wrong way around. First is `nmemb` and
 second is the size of each member:


 {{{
 av_alloc_size(1, 2) void *av_malloc_array(size_t nmemb, size_t size);
 }}}

 This was flagged by gcc's `-Wcalloc-transposed-args`.
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/11620>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list