mirror of
https://github.com/xenia-project/FFmpeg.git
synced 2024-11-24 03:59:43 +00:00
avfilter: check malloc return values.
This commit is contained in:
parent
d969e93a72
commit
0699dbb847
@ -583,29 +583,53 @@ int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *in
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
ret = av_mallocz(sizeof(AVFilterContext));
|
||||
if (!ret)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
ret->av_class = &avfilter_class;
|
||||
ret->filter = filter;
|
||||
ret->name = inst_name ? av_strdup(inst_name) : NULL;
|
||||
if (filter->priv_size)
|
||||
if (filter->priv_size) {
|
||||
ret->priv = av_mallocz(filter->priv_size);
|
||||
if (!ret->priv)
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret->input_count = pad_count(filter->inputs);
|
||||
if (ret->input_count) {
|
||||
ret->input_pads = av_malloc(sizeof(AVFilterPad) * ret->input_count);
|
||||
if (!ret->input_pads)
|
||||
goto err;
|
||||
memcpy(ret->input_pads, filter->inputs, sizeof(AVFilterPad) * ret->input_count);
|
||||
ret->inputs = av_mallocz(sizeof(AVFilterLink*) * ret->input_count);
|
||||
if (!ret->inputs)
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret->output_count = pad_count(filter->outputs);
|
||||
if (ret->output_count) {
|
||||
ret->output_pads = av_malloc(sizeof(AVFilterPad) * ret->output_count);
|
||||
if (!ret->output_pads)
|
||||
goto err;
|
||||
memcpy(ret->output_pads, filter->outputs, sizeof(AVFilterPad) * ret->output_count);
|
||||
ret->outputs = av_mallocz(sizeof(AVFilterLink*) * ret->output_count);
|
||||
if (!ret->outputs)
|
||||
goto err;
|
||||
}
|
||||
|
||||
*filter_ctx = ret;
|
||||
return 0;
|
||||
|
||||
err:
|
||||
av_freep(&ret->inputs);
|
||||
av_freep(&ret->input_pads);
|
||||
ret->input_count = 0;
|
||||
av_freep(&ret->outputs);
|
||||
av_freep(&ret->output_pads);
|
||||
ret->output_count = 0;
|
||||
av_freep(&ret->priv);
|
||||
av_free(ret);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
void avfilter_free(AVFilterContext *filter)
|
||||
|
Loading…
Reference in New Issue
Block a user