#11620: av_malloc_array() and av_realloc_array(): nmemb and size arguments
transposed
------------------------------------+----------------------------------
             Reporter:  francoisk   |                    Owner:  (none)
                 Type:  defect      |                   Status:  new
             Priority:  normal      |                Component:  avutil
              Version:  git-master  |               Resolution:
             Keywords:  memory      |               Blocked By:
             Blocking:              |  Reproduced by developer:  0
Analyzed by developer:  0           |
------------------------------------+----------------------------------
Changes (by francoisk):

 * summary:  av_malloc_array(): nmemb and size arguments transposed =>
     av_malloc_array() and av_realloc_array(): nmemb and size arguments
     transposed


Old description:

> 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`.

New description:

 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);
 }}}

 Same goes for the call to `av_realloc_array()` at line 425 of the same
 file:

 {{{
 tmp = av_realloc_array(dst->extended_buf, sizeof(*dst->extended_buf),
                        src->nb_extended_buf);
 }}}

 This was flagged by gcc's `-Wcalloc-transposed-args`.

--
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/11620#comment:1>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
_______________________________________________
FFmpeg-trac mailing list
FFmpeg-trac@avcodec.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-trac

To unsubscribe, visit link above, or email
ffmpeg-trac-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to