diff options
author | Ronald S. Bultje <rsbultje@gmail.com> | 2011-10-29 16:17:27 -0700 |
---|---|---|
committer | Ronald S. Bultje <rsbultje@gmail.com> | 2011-11-05 06:59:27 -0700 |
commit | 23a8b4ddfca9f7da5da491f33a62269d96927674 (patch) | |
tree | 99d089e1516208788d93f7b9be8b29100e5cc6c1 /libavfilter | |
parent | ea2bb12e3e47baa0f8d50ef68be678f425c7e4cf (diff) | |
download | ffmpeg-23a8b4ddfca9f7da5da491f33a62269d96927674.tar.gz |
avfilter: don't abort() on zero-size allocations.
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/formats.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/libavfilter/formats.c b/libavfilter/formats.c index 848b2ee119..f5a3e458af 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -43,19 +43,21 @@ static void merge_ref(AVFilterFormats *ret, AVFilterFormats *a) AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b) { AVFilterFormats *ret; - unsigned i, j, k = 0; + unsigned i, j, k = 0, m_count; ret = av_mallocz(sizeof(AVFilterFormats)); /* merge list of formats */ - ret->formats = av_malloc(sizeof(*ret->formats) * FFMIN(a->format_count, - b->format_count)); + m_count = FFMIN(a->format_count, b->format_count); + if (m_count) { + ret->formats = av_malloc(sizeof(*ret->formats) * m_count); for(i = 0; i < a->format_count; i ++) for(j = 0; j < b->format_count; j ++) if(a->formats[i] == b->formats[j]) ret->formats[k++] = a->formats[i]; ret->format_count = k; + } /* check that there was at least one common format */ if(!ret->format_count) { av_free(ret->formats); @@ -91,6 +93,7 @@ AVFilterFormats *avfilter_make_format_list(const int *fmts) ; formats = av_mallocz(sizeof(AVFilterFormats)); + if (count) formats->formats = av_malloc(sizeof(*formats->formats) * count); formats->format_count = count; memcpy(formats->formats, fmts, sizeof(*formats->formats) * count); |