[FFmpeg-devel] [PATCH] lavc/options: don't copy priv context when it is not AVOption object

Michael Niedermayer michaelni at gmx.at
Fri Dec 5 00:15:23 CET 2014


On Thu, Dec 04, 2014 at 12:50:06AM +0100, Lukasz Marek wrote:
> On 03.12.2014 01:28, Michael Niedermayer wrote:
> >On Wed, Dec 03, 2014 at 01:24:55AM +0100, Lukasz Marek wrote:
> >>On 03.12.2014 01:15, Michael Niedermayer wrote:
> >>>On Wed, Dec 03, 2014 at 12:06:47AM +0100, Lukasz Marek wrote:
> >>>>This prevents potential crash when opt API is used without a class.
> >>>>
> >>>>Signed-off-by: Lukasz Marek <lukasz.m.luki2 at gmail.com>
> >>>>---
> >>>>  libavcodec/options.c | 2 +-
> >>>>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>>>
> >>>>diff --git a/libavcodec/options.c b/libavcodec/options.c
> >>>>index 7f9fb07..42ef754 100644
> >>>>--- a/libavcodec/options.c
> >>>>+++ b/libavcodec/options.c
> >>>>@@ -196,7 +196,7 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
> >>>>
> >>>>      dest->priv_data       = orig_priv_data;
> >>>>
> >>>>-    if (orig_priv_data)
> >>>>+    if (orig_priv_data && src->codec && src->codec->priv_class)
> >>>>          av_opt_copy(orig_priv_data, src->priv_data);
> >>>>
> >>>
> >>>"&& src->codec->priv_class" <--- LGTM
> >>>the src->codec check is probably ok too but is it NULL ever ?
> >>
> >>after avcodec_alloc_context3(NULL)?
> >>IIRC there was a patch recently that set codec in
> >>avcodec_alloc_context3 (via avcodec_get_context_defaults3) when
> >>provided. Maybe after that it is not so common case. But still when
> >>allocated with NULL then you have NULL there. src context doesn't
> >>have to be open neither.
> >
> >ok
> 
> I'm sorry for doing a mess recently regarding this damn
> avcodec_copy_context function. I'm sending updated patch.
> I will send in a moment patchset with test for it.
> The test doesn't cover everything (it is kinda hard to test it), but
> it should cover options management.
> Just to clear, I will ping in one more in a moment and don't bother
> with any other atm :)
> 

>  options.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 2667b09ea91f32396f7151900b5fa24a8bcabfef  0001-lavc-options-don-t-copy-priv-context-when-it-is-not-.patch
> From d8884452f3bd0af45e459c7c2b2549b7a225ed4d Mon Sep 17 00:00:00 2001
> From: Lukasz Marek <lukasz.m.luki2 at gmail.com>
> Date: Tue, 2 Dec 2014 23:24:15 +0100
> Subject: [PATCH] lavc/options: don't copy priv context when it is not AVOption
>  object
> 
> This prevents potential crash when opt API is used without a class.

LGTM

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20141205/903cf985/attachment.asc>


More information about the ffmpeg-devel mailing list