[FFmpeg-devel] [PATCH] Fix the ffmpeg -rc_eq "foo" bug

Stefano Sabatini stefano.sabatini-lala
Sun Jul 13 18:36:09 CEST 2008


Hi all, currently ffmpeg crashes when setting the option -rc_eq.

There are currently two bugs involved, the first one:

+++ libavcodec/opt.c    (working copy)
@@ -196,7 +196,7 @@
     }

     if(alloc){
-        av_free((void*)(((uint8_t*)obj) + o->offset));
+        av_free(*(void**)(((uint8_t*)obj) + o->offset));
         val= av_strdup(val);
     }

this because obj + o->offset is a pointer to the location which
contains the pointer to the string.

The rc_eq string needs to be strdup()ed in
avcodec_get_context_defaults2 since av_set_string2() may free that
pointer when it sets again the rc_eq string, which issues a SIGSEGV if
the string is static.

Note also that there is a memleak here, the rc_eq set by
avcodec_get_context_defaults2() or by av_set_string() has to be
explicitly freed by the user before to free the AVCodecContext.

Regards.
-- 
FFmpeg = Foolish Frenzy MultiPurpose Elected Gospel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix-av-set-string2-pointer-logic.patch
Type: text/x-diff
Size: 364 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080713/0aa2dd52/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: strdup-rc-eq-00.patch
Type: text/x-diff
Size: 491 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080713/0aa2dd52/attachment-0001.patch>



More information about the ffmpeg-devel mailing list