libav icon indicating copy to clipboard operation
libav copied to clipboard

fix potential null pointer derefrence in get_video_buffer function

Open glorious064 opened this issue 7 months ago • 0 comments

In the libavfilter/vf_yadif.c file, within the get_video_buffer function, there is a possible null pointer dereference:

` frame = ff_default_get_video_buffer(link, width, height);

frame->width = w; frame->height = h; ` However, this implementation does not check whether frame is NULL before dereferencing it. If ff_default_get_video_buffer() fails and returns NULL, this will result in a null pointer dereference, leading to a potential crash.

To address this, I added a null check right after the buffer allocation:

` frame = ff_default_get_video_buffer(link, width, height);

if (!frame) return NULL;

frame->width = w; frame->height = h; `

I’d like to kindly ask the maintainers to confirm whether:

ff_default_get_video_buffer() can return NULL in practice under certain conditions. If so, whether it is necessary to guard all frame accesses accordingly. Please advise if further defensive programming is needed here.

Thank you!

glorious064 avatar Jul 02 '25 09:07 glorious064