[FFmpeg-devel] [PATCH] avcodec/mov: Allocate skipped_bytes_pos with av_realloc.

Michael Niedermayer michael at niedermayer.cc
Fri Sep 1 13:45:40 EEST 2017


On Thu, Aug 31, 2017 at 02:07:43PM -0400, Mark Wachsler wrote:
> Memory reallocated with av_reallocp_array is supposed to be allocated
> with av_realloc, not av_malloc.

Our docs did briefly claim this but it was removed years ago in
21f70940ae106bfffa07e73057cdb4b5e81a767a

Also FFmpeg has been written with av_realloc*() and av_malloc*()
compatibility in mind both before and after 21f70940ae106bfffa07e73057cdb4b5e81a767a
So its not 2 but many more that likely would need to be changed

If there is a incompatibility then
Its easier to fix the incompatibility between av_malloc* and av_realloc*
also it is much more maintainable if they are compatibile.
Code that works on 99.9 % of the developers systems but breaks on the
remaininng 0.1% is really hard to maintain design.

That said iam not against this patch and i can apply it (without tabs)
if people want but this is far from fixing all these issues

DId you try to replace posix_memalign() by aligned_alloc() where its
available?
ISO C requires aligned_alloc() to be compatibile with realloc()
where one can debate the situation of posix_memalign() and realloc()

For reference
    7.22.3 Memory management functions
    ...
    7.22.3.1 The aligned_alloc function

Thus aligned_alloc() is a "Memory management function" in ISO C

In the list of undefined behaviors there is:
    - The pointer argument to the free or realloc function does not match a pointer
      earlier returned by a memory management function, or the space has been deallocated
      by a call to free or realloc (7.22.3.3, 7.22.3.5).

The undefined behavior is clearly limited to pointers not originating
from "Memory management functions", I can see no special case for
aligned_alloc()

In case your implemnatation of aligned_alloc() and realloc() are
incompatibile as well, please fix your implemnatation.

Thanks

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170901/b30e475c/attachment.sig>


More information about the ffmpeg-devel mailing list