mirror of
https://github.com/mpv-player/mpv
synced 2025-01-09 08:29:36 +00:00
av_log: don't crash if called with NULL AVClass
At least libavformat mpegts demuxer may give bad parameters with NULL AVClass to the av_log callback. Check for this and print a warning instead of crashing.
This commit is contained in:
parent
9e6933440a
commit
54d0763b92
8
av_log.c
8
av_log.c
@ -54,6 +54,12 @@ static int extract_msg_type_from_ctx(void *ptr)
|
|||||||
return MSGT_FIXME;
|
return MSGT_FIXME;
|
||||||
|
|
||||||
AVClass *avc = *(AVClass **)ptr;
|
AVClass *avc = *(AVClass **)ptr;
|
||||||
|
if (!avc) {
|
||||||
|
mp_msg(MSGT_FIXME, MSGL_WARN,
|
||||||
|
"av_log callback called with bad parameters (NULL AVClass).\n"
|
||||||
|
"This is a bug in one of Libav/FFmpeg libraries used.\n");
|
||||||
|
return MSGT_FIXME;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_FFMPEG
|
#ifdef CONFIG_FFMPEG
|
||||||
if (!strcmp(avc->class_name, "AVCodecContext")) {
|
if (!strcmp(avc->class_name, "AVCodecContext")) {
|
||||||
@ -71,9 +77,7 @@ static int extract_msg_type_from_ctx(void *ptr)
|
|||||||
}
|
}
|
||||||
return MSGT_FIXME;
|
return MSGT_FIXME;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_FFMPEG
|
|
||||||
if (!strcmp(avc->class_name, "AVFormatContext")) {
|
if (!strcmp(avc->class_name, "AVFormatContext")) {
|
||||||
AVFormatContext *s = ptr;
|
AVFormatContext *s = ptr;
|
||||||
if (s->iformat)
|
if (s->iformat)
|
||||||
|
Loading…
Reference in New Issue
Block a user