summaryrefslogtreecommitdiff
path: root/libavfilter/formats.c
diff options
context:
space:
mode:
authorClément Bœsch <u@pkh.me>2015-03-14 21:21:49 +0100
committerClément Bœsch <u@pkh.me>2015-03-16 23:43:12 +0100
commitf861d9b2c64752b134d49cb9e790b77221c381c1 (patch)
treec6f43bc92e459df9698976679525333a5f1a6a84 /libavfilter/formats.c
parent93d9ce7cec48a4c6478bba4383613fca3f28740a (diff)
avfilter/formats: proper error handling in ff_channel_layouts_ref() and ff_formats_ref()
Also make sure the allocation and its check are properly done.
Diffstat (limited to 'libavfilter/formats.c')
-rw-r--r--libavfilter/formats.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 896ceeba88..6393416cb7 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -400,21 +400,21 @@ AVFilterChannelLayouts *ff_all_channel_counts(void)
return ret;
}
-#define FORMATS_REF(f, ref) \
-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)
-
-void ff_channel_layouts_ref(AVFilterChannelLayouts *f, AVFilterChannelLayouts **ref)
+#define FORMATS_REF(f, ref) \
+ void *tmp = av_realloc_array(f->refs, sizeof(*f->refs), f->refcount + 1); \
+ if (!tmp) \
+ return AVERROR(ENOMEM); \
+ f->refs = tmp; \
+ f->refs[f->refcount++] = ref; \
+ *ref = f; \
+ return 0
+
+int ff_channel_layouts_ref(AVFilterChannelLayouts *f, AVFilterChannelLayouts **ref)
{
FORMATS_REF(f, ref);
}
-void ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
+int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
{
FORMATS_REF(f, ref);
}