1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

filtfmts: Avoid null pointer dereference

This commit is contained in:
Himangi Saraogi 2015-04-03 19:42:11 +05:30 committed by Vittorio Giovara
parent a1d58e3b38
commit 88d1fb4e3f

View File

@ -33,7 +33,7 @@ int main(int argc, char **argv)
AVFilterGraph *graph_ctx; AVFilterGraph *graph_ctx;
const char *filter_name; const char *filter_name;
const char *filter_args = NULL; const char *filter_args = NULL;
int i, j; int i, j, ret = 0;
av_log_set_level(AV_LOG_DEBUG); av_log_set_level(AV_LOG_DEBUG);
@ -74,11 +74,21 @@ int main(int argc, char **argv)
/* create a link for each of the input pads */ /* create a link for each of the input pads */
for (i = 0; i < filter_ctx->nb_inputs; i++) { for (i = 0; i < filter_ctx->nb_inputs; i++) {
AVFilterLink *link = av_mallocz(sizeof(AVFilterLink)); AVFilterLink *link = av_mallocz(sizeof(AVFilterLink));
if (!link) {
fprintf(stderr, "Unable to allocate memory for filter input link\n");
ret = 1;
goto fail;
}
link->type = avfilter_pad_get_type(filter_ctx->filter->inputs, i); link->type = avfilter_pad_get_type(filter_ctx->filter->inputs, i);
filter_ctx->inputs[i] = link; filter_ctx->inputs[i] = link;
} }
for (i = 0; i < filter_ctx->nb_outputs; i++) { for (i = 0; i < filter_ctx->nb_outputs; i++) {
AVFilterLink *link = av_mallocz(sizeof(AVFilterLink)); AVFilterLink *link = av_mallocz(sizeof(AVFilterLink));
if (!link) {
fprintf(stderr, "Unable to allocate memory for filter output link\n");
ret = 1;
goto fail;
}
link->type = avfilter_pad_get_type(filter_ctx->filter->outputs, i); link->type = avfilter_pad_get_type(filter_ctx->filter->outputs, i);
filter_ctx->outputs[i] = link; filter_ctx->outputs[i] = link;
} }
@ -106,8 +116,9 @@ int main(int argc, char **argv)
av_get_pix_fmt_name(fmts->formats[j])); av_get_pix_fmt_name(fmts->formats[j]));
} }
fail:
avfilter_free(filter_ctx); avfilter_free(filter_ctx);
avfilter_graph_free(&graph_ctx); avfilter_graph_free(&graph_ctx);
fflush(stdout); fflush(stdout);
return 0; return ret;
} }