Fixes crash
Fixes Ticket5412
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 78baa450d9939957f52d5187beb95d763d2f1f18)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
... | ... |
@@ -26,6 +26,7 @@ |
26 | 26 |
#include "libavutil/opt.h" |
27 | 27 |
#include "libavutil/avassert.h" |
28 | 28 |
#include "libavutil/avstring.h" |
29 |
+#include "libavutil/pixdesc.h" |
|
29 | 30 |
#include "avformat.h" |
30 | 31 |
#include "internal.h" |
31 | 32 |
#include "ffm.h" |
... | ... |
@@ -365,6 +366,11 @@ static int ffm2_read_header(AVFormatContext *s) |
365 | 365 |
codec->height = avio_rb16(pb); |
366 | 366 |
codec->gop_size = avio_rb16(pb); |
367 | 367 |
codec->pix_fmt = avio_rb32(pb); |
368 |
+ if (!av_pix_fmt_desc_get(codec->pix_fmt)) { |
|
369 |
+ av_log(s, AV_LOG_ERROR, "Invalid pix fmt id: %d\n", codec->pix_fmt); |
|
370 |
+ codec->pix_fmt = AV_PIX_FMT_NONE; |
|
371 |
+ goto fail; |
|
372 |
+ } |
|
368 | 373 |
codec->qmin = avio_r8(pb); |
369 | 374 |
codec->qmax = avio_r8(pb); |
370 | 375 |
codec->max_qdiff = avio_r8(pb); |
... | ... |
@@ -557,6 +563,11 @@ static int ffm_read_header(AVFormatContext *s) |
557 | 557 |
codec->height = avio_rb16(pb); |
558 | 558 |
codec->gop_size = avio_rb16(pb); |
559 | 559 |
codec->pix_fmt = avio_rb32(pb); |
560 |
+ if (!av_pix_fmt_desc_get(codec->pix_fmt)) { |
|
561 |
+ av_log(s, AV_LOG_ERROR, "Invalid pix fmt id: %d\n", codec->pix_fmt); |
|
562 |
+ codec->pix_fmt = AV_PIX_FMT_NONE; |
|
563 |
+ goto fail; |
|
564 |
+ } |
|
560 | 565 |
codec->qmin = avio_r8(pb); |
561 | 566 |
codec->qmax = avio_r8(pb); |
562 | 567 |
codec->max_qdiff = avio_r8(pb); |