On 01/10/2016 02:20 AM, Michael Niedermayer wrote:

+        if (!(track->codec_priv.data = av_realloc(track->codec_priv.data,
+                track->codec_priv.size + 4)))
+            return AVERROR(ENOMEM);

in case of this failing the memory is not freed and leaks

see av_reallocp() if you want it to be freed, alternatively the code
could continue without the move/update


OK, but I thought an AVERROR(ENOMEM) eventually causes FFmpeg to exit?

And another thing: I notice the following regarding both av_realloc() and av_reallocp():

"Pointers originating from the av_malloc() family of functions must not be passed to av_realloc(). The former can be implemented using memalign() (or other functions), and there is no guarantee that pointers from such functions can be passed to realloc() at all. The situation is undefined according to POSIX and may crash with some libc implementations."

I suppose that ebml_read_binary() in matroskadec.c is the function used to read the private data, and it allocates memory using av_fast_padded_malloc() for this. Is it safe to reallocate a pointer from this function then? So far I've had no problems, but of course I want to be absolutely sure.

Mats

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to