mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-13 10:30:05 +01:00
avformat/ffmdec: Check pix_fmt
Fixes crash
Fixes Ticket5412
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 78baa450d9)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
#include "libavutil/opt.h"
|
#include "libavutil/opt.h"
|
||||||
#include "libavutil/avassert.h"
|
#include "libavutil/avassert.h"
|
||||||
#include "libavutil/avstring.h"
|
#include "libavutil/avstring.h"
|
||||||
|
#include "libavutil/pixdesc.h"
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "ffm.h"
|
#include "ffm.h"
|
||||||
@@ -365,6 +366,11 @@ static int ffm2_read_header(AVFormatContext *s)
|
|||||||
codec->height = avio_rb16(pb);
|
codec->height = avio_rb16(pb);
|
||||||
codec->gop_size = avio_rb16(pb);
|
codec->gop_size = avio_rb16(pb);
|
||||||
codec->pix_fmt = avio_rb32(pb);
|
codec->pix_fmt = avio_rb32(pb);
|
||||||
|
if (!av_pix_fmt_desc_get(codec->pix_fmt)) {
|
||||||
|
av_log(s, AV_LOG_ERROR, "Invalid pix fmt id: %d\n", codec->pix_fmt);
|
||||||
|
codec->pix_fmt = AV_PIX_FMT_NONE;
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
codec->qmin = avio_r8(pb);
|
codec->qmin = avio_r8(pb);
|
||||||
codec->qmax = avio_r8(pb);
|
codec->qmax = avio_r8(pb);
|
||||||
codec->max_qdiff = avio_r8(pb);
|
codec->max_qdiff = avio_r8(pb);
|
||||||
@@ -556,6 +562,11 @@ static int ffm_read_header(AVFormatContext *s)
|
|||||||
codec->height = avio_rb16(pb);
|
codec->height = avio_rb16(pb);
|
||||||
codec->gop_size = avio_rb16(pb);
|
codec->gop_size = avio_rb16(pb);
|
||||||
codec->pix_fmt = avio_rb32(pb);
|
codec->pix_fmt = avio_rb32(pb);
|
||||||
|
if (!av_pix_fmt_desc_get(codec->pix_fmt)) {
|
||||||
|
av_log(s, AV_LOG_ERROR, "Invalid pix fmt id: %d\n", codec->pix_fmt);
|
||||||
|
codec->pix_fmt = AV_PIX_FMT_NONE;
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
codec->qmin = avio_r8(pb);
|
codec->qmin = avio_r8(pb);
|
||||||
codec->qmax = avio_r8(pb);
|
codec->qmax = avio_r8(pb);
|
||||||
codec->max_qdiff = avio_r8(pb);
|
codec->max_qdiff = avio_r8(pb);
|
||||||
|
|||||||
Reference in New Issue
Block a user