From 6568b7df704cc55576a05c55afd9722629dc076a Mon Sep 17 00:00:00 2001 From: Xinzheng Zhang Date: Mon, 5 Sep 2016 15:36:15 +0800 Subject: [PATCH] ios/videotoolbox: fix error checking for size of extra_data --- .../android/pipeline/ffpipenode_android_mediacodec_vdec.c | 3 ++- .../ijkmedia/ijkplayer/ios/pipeline/IJKVideoToolBox.m | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ijkmedia/ijkplayer/android/pipeline/ffpipenode_android_mediacodec_vdec.c b/ijkmedia/ijkplayer/android/pipeline/ffpipenode_android_mediacodec_vdec.c index 93713923..2e7a27de 100644 --- a/ijkmedia/ijkplayer/android/pipeline/ffpipenode_android_mediacodec_vdec.c +++ b/ijkmedia/ijkplayer/android/pipeline/ffpipenode_android_mediacodec_vdec.c @@ -447,7 +447,8 @@ static int feed_input_buffer(JNIEnv *env, IJKFF_Pipenode *node, int64_t timeUs, int size_data_size = 0; AVPacket *avpkt = &d->pkt_temp; size_data = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, &size_data_size); - if (size_data && size_data_size > AV_INPUT_BUFFER_PADDING_SIZE) { + // minimum avcC(sps,pps) = 7 + if (size_data && size_data_size >= 7) { int got_picture = 0; AVFrame *frame = av_frame_alloc(); AVDictionary *codec_opts = NULL; diff --git a/ios/IJKMediaPlayer/IJKMediaPlayer/ijkmedia/ijkplayer/ios/pipeline/IJKVideoToolBox.m b/ios/IJKMediaPlayer/IJKMediaPlayer/ijkmedia/ijkplayer/ios/pipeline/IJKVideoToolBox.m index ecdb43d6..6fc94731 100644 --- a/ios/IJKMediaPlayer/IJKMediaPlayer/ijkmedia/ijkplayer/ios/pipeline/IJKVideoToolBox.m +++ b/ios/IJKMediaPlayer/IJKMediaPlayer/ijkmedia/ijkplayer/ios/pipeline/IJKVideoToolBox.m @@ -760,7 +760,8 @@ static int decode_video(VideoToolBoxContext* context, AVCodecContext *avctx, AVP if (context->ffp->vtb_handle_resolution_change && context->codecpar->codec_id == AV_CODEC_ID_H264) { size_data = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, &size_data_size); - if (size_data && size_data_size > AV_INPUT_BUFFER_PADDING_SIZE) { + // avcC(sps,pps) of size, minimum is 7 + if (size_data && size_data_size > 7) { int got_picture = 0; AVFrame *frame = av_frame_alloc(); AVDictionary *codec_opts = NULL; @@ -770,7 +771,7 @@ static int decode_video(VideoToolBoxContext* context, AVCodecContext *avctx, AVP avcodec_parameters_to_context(new_avctx, context->codecpar); av_freep(&new_avctx->extradata); - new_avctx->extradata = av_mallocz(size_data_size); + new_avctx->extradata = av_mallocz(size_data_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!new_avctx->extradata) return AVERROR(ENOMEM); memcpy(new_avctx->extradata, size_data, size_data_size); -- GitLab