aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-10-25 13:17:26 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-10-25 13:28:51 +0200
commit2fc970a6b84504f54883a25482de466b49b11fd8 (patch)
treed910d49a04c7012cf51d7f98b1f21799f5daaf56
parent92d366f6abf85ebff5f0562894c8f94ebe80f114 (diff)
downloadffmpeg-2fc970a6b84504f54883a25482de466b49b11fd8.tar.gz
cmdutils: Read errno before av_log() as the callback from av_log() might affect errno
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--cmdutils.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/cmdutils.c b/cmdutils.c
index 7353dd50c5..46bfcca4ec 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -959,9 +959,10 @@ static int init_report(const char *env)
report_file = fopen(filename.str, "w");
if (!report_file) {
+ int ret = AVERROR(errno);
av_log(NULL, AV_LOG_ERROR, "Failed to open report \"%s\": %s\n",
filename.str, strerror(errno));
- return AVERROR(errno);
+ return ret;
}
av_log_set_callback(log_callback_report);
av_log(NULL, AV_LOG_INFO,
@@ -1863,17 +1864,19 @@ int cmdutils_read_file(const char *filename, char **bufptr, size_t *size)
FILE *f = av_fopen_utf8(filename, "rb");
if (!f) {
+ ret = AVERROR(errno);
av_log(NULL, AV_LOG_ERROR, "Cannot read file '%s': %s\n", filename,
strerror(errno));
- return AVERROR(errno);
+ return ret;
}
fseek(f, 0, SEEK_END);
*size = ftell(f);
fseek(f, 0, SEEK_SET);
if (*size == (size_t)-1) {
+ ret = AVERROR(errno);
av_log(NULL, AV_LOG_ERROR, "IO error: %s\n", strerror(errno));
fclose(f);
- return AVERROR(errno);
+ return ret;
}
*bufptr = av_malloc(*size + 1);
if (!*bufptr) {
@@ -1885,9 +1888,9 @@ int cmdutils_read_file(const char *filename, char **bufptr, size_t *size)
if (ret < *size) {
av_free(*bufptr);
if (ferror(f)) {
+ ret = AVERROR(errno);
av_log(NULL, AV_LOG_ERROR, "Error while reading file '%s': %s\n",
filename, strerror(errno));
- ret = AVERROR(errno);
} else
ret = AVERROR_EOF;
} else {