* qatar/master: (23 commits) doc: Check standalone compilation before submitting new components. Fix standalone compilation of pipe protocol. Fix standalone compilation of ac3_fixed encoder. Fix standalone compilation of binkaudio_dct / binkaudio_rdft decoders. Fix standalone compilation of IMC decoder. Fix standalone compilation of WTV demuxer. Fix standalone compilation of MXPEG decoder. flashsv: K&R cosmetics matroskaenc: fix memory leak vc1: make overlap filter for I-frames bit-exact. vc1dec: use s->start/end_mb_y instead of passing them as function args. Revert "VC1: merge idct8x8, coeff adjustments and put_pixels." Replace strncpy() with av_strlcpy(). indeo3: Eliminate use of long. get_bits: make cache unsigned to eliminate undefined signed overflow. asfdec: fix assert failure on invalid files avfilter: check malloc return values. Not pulled as reason for reindent is not pulled: mpegvideo: reindent. nutenc: check malloc return values. Not pulled due to much simpler solution in ffmpeg *: don't av_malloc(0). ... Conflicts: doc/developer.texi libavcodec/Makefile libavcodec/get_bits.h libavcodec/mpegvideo.c libavformat/Makefile libavutil/log.c
Showing the changes to libavfilter/avfilter.c (1 of 25 files). Show all
Unified · Split
| @@ -585,28 +585,53 @@ int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *in · 584 unmodified lines | ||
| 585 | 585 | return AVERROR(EINVAL); |
| 586 | 586 | |
| 587 | 587 | ret = av_mallocz(sizeof(AVFilterContext)); |
| 588 | + if (!ret) | |
| 589 | + return AVERROR(ENOMEM); | |
| 588 | 590 | |
| 589 | 591 | ret->av_class = &avfilter_class; |
| 590 | 592 | ret->filter = filter; |
| 591 | 593 | ret->name = inst_name ? av_strdup(inst_name) : NULL; |
| 592 | − ret->priv = av_mallocz(filter->priv_size); | |
| 594 | + if (filter->priv_size) { | |
| 595 | + ret->priv = av_mallocz(filter->priv_size); | |
| 596 | + if (!ret->priv) | |
| 597 | + goto err; | |
| 598 | + } | |
| 593 | 599 | |
| 594 | 600 | ret->input_count = pad_count(filter->inputs); |
| 595 | 601 | if (ret->input_count) { |
| 596 | 602 | ret->input_pads = av_malloc(sizeof(AVFilterPad) * ret->input_count); |
| 603 | + if (!ret->input_pads) | |
| 604 | + goto err; | |
| 597 | 605 | memcpy(ret->input_pads, filter->inputs, sizeof(AVFilterPad) * ret->input_count); |
| 598 | 606 | ret->inputs = av_mallocz(sizeof(AVFilterLink*) * ret->input_count); |
| 607 | + if (!ret->inputs) | |
| 608 | + goto err; | |
| 599 | 609 | } |
| 600 | 610 | |
| 601 | 611 | ret->output_count = pad_count(filter->outputs); |
| 602 | 612 | if (ret->output_count) { |
| 603 | 613 | ret->output_pads = av_malloc(sizeof(AVFilterPad) * ret->output_count); |
| 614 | + if (!ret->output_pads) | |
| 615 | + goto err; | |
| 604 | 616 | memcpy(ret->output_pads, filter->outputs, sizeof(AVFilterPad) * ret->output_count); |
| 605 | 617 | ret->outputs = av_mallocz(sizeof(AVFilterLink*) * ret->output_count); |
| 618 | + if (!ret->outputs) | |
| 619 | + goto err; | |
| 606 | 620 | } |
| 607 | 621 | |
| 608 | 622 | *filter_ctx = ret; |
| 609 | 623 | return 0; |
| 624 | + | |
| 625 | +err: | |
| 626 | + av_freep(&ret->inputs); | |
| 627 | + av_freep(&ret->input_pads); | |
| 628 | + ret->input_count = 0; | |
| 629 | + av_freep(&ret->outputs); | |
| 630 | + av_freep(&ret->output_pads); | |
| 631 | + ret->output_count = 0; | |
| 632 | + av_freep(&ret->priv); | |
| 633 | + av_free(ret); | |
| 634 | + return AVERROR(ENOMEM); | |
| 610 | 635 | } |
| 611 | 636 | |
| 612 | 637 | void avfilter_free(AVFilterContext *filter) |