[MPlayer-dev-eng] [patch] malloc padding

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Sun Dec 18 21:40:11 CET 2005


Hi,
On Sat, Dec 17, 2005 at 06:45:07PM +0100, Jindrich Makovicka wrote:
> this patch adds the malloc padding to several places to avoid reading 
> past the malloc()ed area by libavcodec.
> 
> Credits to Mikulas Patocka (mikulas at artax karlin mff cuni cz)
> 
> Ok to apply?

I dislike it but if it is the only way to fix...

>     mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\n");
> -   if(!videobuffer) videobuffer=(char*)memalign(8,VIDEOBUFFER_SIZE);
> -   if(!videobuffer){ 
> -     mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_ShMemAllocFail);
> -     return 0;
> +   if(!videobuffer) {
> +     videobuffer=(char*)memalign(8,VIDEOBUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
> +     if (videobuffer) memset(videobuffer+VIDEOBUFFER_SIZE, 0, FF_INPUT_BUFFER_PADDING_SIZE);
> +     else {
> +       mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_ShMemAllocFail);
> +       return 0;
> +     }

You can make these parts of the patch three lines shorted by putting the
memset into the else part of the already existing "if(!videobuffer)".

Greetings,
Reimar Döffinger




More information about the MPlayer-dev-eng mailing list