On Sun, Sep 08, 2013 at 08:09:17AM +0200, Luca Barbato wrote: > Passing a pointer provided by memalign, posix_memalign or aligned_alloc to > realloc is known to cause subtle or not so subtle errors resulting in > possible crashes in most libc (the openbsd and windows ones are the > exceptions).
libcs > The Libav code does not mix av_malloc and av_realloc functions so does so it > --- a/libavutil/mem.h > +++ b/libavutil/mem.h > @@ -100,14 +100,14 @@ av_alloc_size(1, 2) static inline void > *av_malloc_array(size_t nmemb, size_t siz > * Allocate or reallocate a block of memory. > * If ptr is NULL and size > 0, allocate a new block. If > * size is zero, free the memory block pointed to by ptr. > + * @note Pointers provided by av_malloc family of functions cannot be > + * passed to av_realloc(). > * @param ptr Pointer to a memory block already allocated with > * av_realloc() or NULL. > * @param size Size in bytes of the memory block to be allocated or > * reallocated. > * @return Pointer to a newly-reallocated block or NULL if the block > * cannot be reallocated or the function is used to free the memory block. > - * @note av_realloc() is not guaranteed to maintain the alignment of > - * pointers originating from the av_malloc() family of functions. > * @see av_fast_realloc() > */ This brings back the previous unclear wording. You can very much pass pointers from av_malloc() to av_realloc() - it's just that the result may surprise you. There is an extensive explanation in the log message, some of it should end up in this note as well. Diego _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
