Skip to content

Commit

Permalink
ios/videotoolbox: fix error checking for size of extra_data
Browse files Browse the repository at this point in the history
  • Loading branch information
xinzhengzhang committed Sep 6, 2016
1 parent cb49cf1 commit 6568b7d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 6568b7d

Please sign in to comment.