summaryrefslogtreecommitdiff
path: root/libavfilter/formats.c
diff options
context:
space:
mode:
authorVittorio Giovara <vittorio.giovara@gmail.com>2015-03-12 15:34:32 +0000
committerVittorio Giovara <vittorio.giovara@gmail.com>2015-03-12 17:46:47 +0000
commitc3bd1d60af97e8d2568dac9fcce7bdabb4ff93c8 (patch)
treec6be3154d98aeaaae909dd456729c07bef47b7d1 /libavfilter/formats.c
parent5a2645cafeca1c2207ac55cc831c3349572a82ed (diff)
formats: Check memory allocations
Diffstat (limited to 'libavfilter/formats.c')
-rw-r--r--libavfilter/formats.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index ea61ed2da6..4b6b3aa3b7 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -171,8 +171,15 @@ AVFilterFormats *ff_make_format_list(const int *fmts)
;
formats = av_mallocz(sizeof(*formats));
- if (count)
+ if (!formats)
+ return NULL;
+ if (count) {
formats->formats = av_malloc(sizeof(*formats->formats) * count);
+ if (!formats->formats) {
+ av_freep(&formats);
+ return NULL;
+ }
+ }
formats->nb_formats = count;
memcpy(formats->formats, fmts, sizeof(*formats->formats) * count);
@@ -257,6 +264,8 @@ AVFilterChannelLayouts *ff_all_channel_layouts(void)
do { \
*ref = f; \
f->refs = av_realloc(f->refs, sizeof(*f->refs) * ++f->refcount); \
+ if (!f->refs) \
+ return; \
f->refs[f->refcount-1] = ref; \
} while (0)