Some received packets can have size 0. The return value from
av_malloc(0) may be NULL, which is ok if the size was 0. On
OS X, however, the returned pointer is non-null but leads to
crashes when trying to free it.
Signed-off-by: Martin Storsjö <martin@martin.st>
strtol could return negative values, leading to various error messages,
mainly "non-monotonically increasing dts".
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Since a private class is set for this muxer, the callers will
assume that the private data starts with an AVClass pointer.
If no such member exists, the first few bytes of the struct
will be overwritten, and the class pointer may be broken at
any later time.
Signed-off-by: Martin Storsjö <martin@martin.st>
asf_read_seek() inside the asf demuxer already does the
right thing, it tries the index and if that fails it uses
binary search. If binary search is called from outside of asfdec.c
it will fail because the asf code cannot clean up after itself.
Therefore introduce AVFMT_NOBINSEARCH that prevents the seek
code to fallback to binary search and AVFMT_NOGENSEARCH that
prevents the seek code to fallback to generic search.
The later parsing of payload data depends on the configuration
being present. If it hasn't been configured properly yet,
parsing a data packet may lead to a crash.
Signed-off-by: Martin Storsjö <martin@martin.st>
In the main loop, stream_number is incremented after checking the stream type,
so the search usually will not find the wanted stream.
This patch eliminates the useless stream_number variable and introduces a new
one, called real_stream_index to store the real stream index of the current
stream, no matter if we are looping through all the streams or only the streams
of a program.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Yet another fix for the code originally designed for use without related_stream.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
This avoids the creation of a new AVStream instead of replacing it when
a stream reset occurs (track change with some webradios for example).
Signed-off-by: Diego Biurrun <diego@biurrun.de>
Adding _POSIX_C_SOURCE to CPPFLAGS globally produces all sorts of problems
since it causes certain system functions to be hidden on some (BSD) systems.
The solution is to only add the flag on systems that really require it, i.e.
glibc-based ones.
This change makes BSD systems compile out-of-the-box without the need for
adding specific flags manually. It also allows dropping a number of flags
set manually on a file-per-file basis, but were only present to work around
breakage introduced by the presence of _POSIX_C_SOURCE.
Also add _XOPEN_SOURCE to CPPFLAGS for glibc systems. We use XSI extensions
in several places already, so it is preferable to define it globally instead
of littering source files with individual #defines only needed for glibc.