diff options
author | Anton Khirnov <anton@khirnov.net> | 2023-07-13 17:50:16 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-07-20 20:40:26 +0200 |
commit | 6be4a2939712136fd83aba2a843c8900829a73c2 (patch) | |
tree | 5dd2c0d1a8559659989608b7151c37f3dbe04594 /fftools/ffmpeg_filter.c | |
parent | 8eb5adeab87b8f5a367e0f6b39de53c0bf65a9a2 (diff) | |
download | ffmpeg-6be4a2939712136fd83aba2a843c8900829a73c2.tar.gz |
fftools/cmdutils: add error handling to allocate_array_elem()
Diffstat (limited to 'fftools/ffmpeg_filter.c')
-rw-r--r-- | fftools/ffmpeg_filter.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 538cf6cd43..925b5116cc 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -550,8 +550,10 @@ static OutputFilter *ofilter_alloc(FilterGraph *fg) OutputFilterPriv *ofp; OutputFilter *ofilter; - ofp = allocate_array_elem(&fg->outputs, sizeof(*ofp), - &fg->nb_outputs); + ofp = allocate_array_elem(&fg->outputs, sizeof(*ofp), &fg->nb_outputs); + if (!ofp) + return NULL; + ofilter = &ofp->ofilter; ofilter->graph = fg; ofp->format = -1; @@ -715,10 +717,14 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost) static InputFilter *ifilter_alloc(FilterGraph *fg) { - InputFilterPriv *ifp = allocate_array_elem(&fg->inputs, sizeof(*ifp), - &fg->nb_inputs); - InputFilter *ifilter = &ifp->ifilter; + InputFilterPriv *ifp; + InputFilter *ifilter; + ifp = allocate_array_elem(&fg->inputs, sizeof(*ifp), &fg->nb_inputs); + if (!ifp) + return NULL; + + ifilter = &ifp->ifilter; ifilter->graph = fg; ifp->frame = av_frame_alloc(); @@ -800,13 +806,18 @@ static const AVClass fg_class = { int fg_create(FilterGraph **pfg, char *graph_desc) { - FilterGraphPriv *fgp = allocate_array_elem(&filtergraphs, sizeof(*fgp), &nb_filtergraphs); - FilterGraph *fg = &fgp->fg; + FilterGraphPriv *fgp; + FilterGraph *fg; AVFilterInOut *inputs, *outputs; AVFilterGraph *graph; int ret = 0; + fgp = allocate_array_elem(&filtergraphs, sizeof(*fgp), &nb_filtergraphs); + if (!fgp) + return AVERROR(ENOMEM); + fg = &fgp->fg; + if (pfg) *pfg = fg; @@ -851,6 +862,9 @@ int fg_create(FilterGraph **pfg, char *graph_desc) for (AVFilterInOut *cur = outputs; cur; cur = cur->next) { OutputFilter *const ofilter = ofilter_alloc(fg); + if (!ofilter) + goto fail; + ofilter->linklabel = cur->name; cur->name = NULL; |