From b72814755bd089d657cd594bcd511ec6d45d0c66 Mon Sep 17 00:00:00 2001 From: Taner Sener Date: Fri, 12 Apr 2024 23:46:31 +0100 Subject: [PATCH] replace exit calls with exit_program, fixes #874 --- .../src/main/cpp/fftools_ffprobe.c | 20 ++++++++++++------- apple/src/fftools_ffprobe.c | 20 ++++++++++++------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/android/ffmpeg-kit-android-lib/src/main/cpp/fftools_ffprobe.c b/android/ffmpeg-kit-android-lib/src/main/cpp/fftools_ffprobe.c index dccd966..2403742 100644 --- a/android/ffmpeg-kit-android-lib/src/main/cpp/fftools_ffprobe.c +++ b/android/ffmpeg-kit-android-lib/src/main/cpp/fftools_ffprobe.c @@ -3383,8 +3383,10 @@ static int open_input_file(InputFile *ifile, const char *filename, av_dump_format(fmt_ctx, 0, filename, 0); ifile->streams = av_calloc(fmt_ctx->nb_streams, sizeof(*ifile->streams)); - if (!ifile->streams) - exit(1); + if (!ifile->streams) { + av_log(NULL, AV_LOG_ERROR, "Cannot allocate memory\n"); + exit_program(1); + } ifile->nb_streams = fmt_ctx->nb_streams; /* bind a decoder to each input stream */ @@ -3414,12 +3416,16 @@ static int open_input_file(InputFile *ifile, const char *filename, fmt_ctx, stream, codec); ist->dec_ctx = avcodec_alloc_context3(codec); - if (!ist->dec_ctx) - exit(1); + if (!ist->dec_ctx) { + av_log(NULL, AV_LOG_ERROR, "Cannot allocate an AVCodecContext\n"); + exit_program(1); + } err = avcodec_parameters_to_context(ist->dec_ctx, stream->codecpar); - if (err < 0) - exit(1); + if (err < 0) { + av_log(NULL, AV_LOG_ERROR, "Cannot fill the codec context\n"); + exit_program(1); + } if (do_show_log) { // For loging it is needed to disable at least frame threads as otherwise @@ -3433,7 +3439,7 @@ static int open_input_file(InputFile *ifile, const char *filename, if (avcodec_open2(ist->dec_ctx, codec, &opts) < 0) { av_log(NULL, AV_LOG_WARNING, "Could not open codec for input stream %d\n", stream->index); - exit(1); + exit_program(1); } if ((t = av_dict_get(opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) { diff --git a/apple/src/fftools_ffprobe.c b/apple/src/fftools_ffprobe.c index dccd966..2403742 100644 --- a/apple/src/fftools_ffprobe.c +++ b/apple/src/fftools_ffprobe.c @@ -3383,8 +3383,10 @@ static int open_input_file(InputFile *ifile, const char *filename, av_dump_format(fmt_ctx, 0, filename, 0); ifile->streams = av_calloc(fmt_ctx->nb_streams, sizeof(*ifile->streams)); - if (!ifile->streams) - exit(1); + if (!ifile->streams) { + av_log(NULL, AV_LOG_ERROR, "Cannot allocate memory\n"); + exit_program(1); + } ifile->nb_streams = fmt_ctx->nb_streams; /* bind a decoder to each input stream */ @@ -3414,12 +3416,16 @@ static int open_input_file(InputFile *ifile, const char *filename, fmt_ctx, stream, codec); ist->dec_ctx = avcodec_alloc_context3(codec); - if (!ist->dec_ctx) - exit(1); + if (!ist->dec_ctx) { + av_log(NULL, AV_LOG_ERROR, "Cannot allocate an AVCodecContext\n"); + exit_program(1); + } err = avcodec_parameters_to_context(ist->dec_ctx, stream->codecpar); - if (err < 0) - exit(1); + if (err < 0) { + av_log(NULL, AV_LOG_ERROR, "Cannot fill the codec context\n"); + exit_program(1); + } if (do_show_log) { // For loging it is needed to disable at least frame threads as otherwise @@ -3433,7 +3439,7 @@ static int open_input_file(InputFile *ifile, const char *filename, if (avcodec_open2(ist->dec_ctx, codec, &opts) < 0) { av_log(NULL, AV_LOG_WARNING, "Could not open codec for input stream %d\n", stream->index); - exit(1); + exit_program(1); } if ((t = av_dict_get(opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {