[FFmpeg-devel] [PATCH] lavd/alsa-audio-common: dont crash while closing not opened device

Lukasz Marek lukasz.m.luki2 at gmail.com
Tue Dec 16 15:42:54 CET 2014

On 15 December 2014 at 14:05, Nicolas George <george at nsup.org> wrote:
> Le quintidi 25 frimaire, an CCXXIII, Lukasz Marek a écrit :
> > for example
> > ffmpeg -f alsa -i  aaaa -f alsa aaa
> > would crash if ffmpeg tried to close alsa after open fail. It doesn't so
> it
> > doesn't occur.
> >
> > This commit also make safe to call close function twice on the same
> context
> In that case, I am not sure if that is such a good idea. Applications
> should
> not

should not or must not? It is a big difference and I'm not sure it is
documented anywhere

> be calling av_write_trailer() on unopened contexts, it is not a benign
> operation like free(). But I will not insist on it.

To be precise I've got crash after applying patch from:

and using ./ffmpeg -sources alsa

The mentioned commit is a bit wrong because it makes avformat_open_input to
not call read_header, but close callback is called later inside
This situation is wrong and I will fix it. Calling close callback without
read_header called earlier may be dangerous - right.
After that this commit will probably not be needed, but why you think
crash, even after wrong? use is not worth to fix?
IMHO doxy may states that close in not needed after open fail, but crash is
a bit wrong in this case.
Also it is not user-friendly design. Error handling section is getting
complicated a bit more...

More information about the ffmpeg-devel mailing list