[FFmpeg-devel] Patch: explicitly initialize AVFormatContext *ic = NULL
Art Clarke
aclarke
Fri Jul 10 20:55:57 CEST 2009
On Thu, Jul 9, 2009 at 7:41 PM, avcoder <ffmpeg at gmail.com> wrote:
> >> But IMHO, Initialize AVForamatContext *ic = NULL is a safe coding
> >> style, and this modification unifies coding style with other
> >> av_open_input_file() usages in ffmpeg internal source code
> >
> > The problem is that =NULL is in the applications (ffmpeg/ffplay/...)
> > and the ABI/API does not seem to require it, adding that requirement
> > makes libav incompatible with old applications ...
>
> I see, so revert is a better choice
Or, actually special case the original problem; a caller has pre-allocated a
context and passed it in (wherein av_open_input_file assumes memory
ownership). Patch attached.
- Art
--
http://www.xuggle.com/
xu?ggle (z?' gl) v. To freely encode, decode, and experience audio and
video.
Use Xuggle to get the power of FFmpeg in Java.
-------------- next part --------------
Index: libavformat/utils.c
===================================================================
--- libavformat/utils.c (revision 19394)
+++ libavformat/utils.c (working copy)
@@ -499,7 +499,10 @@
av_freep(&pd->buf);
if (pb)
url_fclose(pb);
- av_freep(ic_ptr);
+ if (ap && ap->prealloced_context)
+ av_freep(ic_ptr);
+ else
+ *ic_ptr = NULL;
return err;
}
More information about the ffmpeg-devel
mailing list