You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
cmdutils: Read errno before av_log() as the callback from av_log() might affect errno
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
11
cmdutils.c
11
cmdutils.c
@@ -959,9 +959,10 @@ static int init_report(const char *env)
|
|||||||
|
|
||||||
report_file = fopen(filename.str, "w");
|
report_file = fopen(filename.str, "w");
|
||||||
if (!report_file) {
|
if (!report_file) {
|
||||||
|
int ret = AVERROR(errno);
|
||||||
av_log(NULL, AV_LOG_ERROR, "Failed to open report \"%s\": %s\n",
|
av_log(NULL, AV_LOG_ERROR, "Failed to open report \"%s\": %s\n",
|
||||||
filename.str, strerror(errno));
|
filename.str, strerror(errno));
|
||||||
return AVERROR(errno);
|
return ret;
|
||||||
}
|
}
|
||||||
av_log_set_callback(log_callback_report);
|
av_log_set_callback(log_callback_report);
|
||||||
av_log(NULL, AV_LOG_INFO,
|
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");
|
FILE *f = av_fopen_utf8(filename, "rb");
|
||||||
|
|
||||||
if (!f) {
|
if (!f) {
|
||||||
|
ret = AVERROR(errno);
|
||||||
av_log(NULL, AV_LOG_ERROR, "Cannot read file '%s': %s\n", filename,
|
av_log(NULL, AV_LOG_ERROR, "Cannot read file '%s': %s\n", filename,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
return AVERROR(errno);
|
return ret;
|
||||||
}
|
}
|
||||||
fseek(f, 0, SEEK_END);
|
fseek(f, 0, SEEK_END);
|
||||||
*size = ftell(f);
|
*size = ftell(f);
|
||||||
fseek(f, 0, SEEK_SET);
|
fseek(f, 0, SEEK_SET);
|
||||||
if (*size == (size_t)-1) {
|
if (*size == (size_t)-1) {
|
||||||
|
ret = AVERROR(errno);
|
||||||
av_log(NULL, AV_LOG_ERROR, "IO error: %s\n", strerror(errno));
|
av_log(NULL, AV_LOG_ERROR, "IO error: %s\n", strerror(errno));
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return AVERROR(errno);
|
return ret;
|
||||||
}
|
}
|
||||||
*bufptr = av_malloc(*size + 1);
|
*bufptr = av_malloc(*size + 1);
|
||||||
if (!*bufptr) {
|
if (!*bufptr) {
|
||||||
@@ -1885,9 +1888,9 @@ int cmdutils_read_file(const char *filename, char **bufptr, size_t *size)
|
|||||||
if (ret < *size) {
|
if (ret < *size) {
|
||||||
av_free(*bufptr);
|
av_free(*bufptr);
|
||||||
if (ferror(f)) {
|
if (ferror(f)) {
|
||||||
|
ret = AVERROR(errno);
|
||||||
av_log(NULL, AV_LOG_ERROR, "Error while reading file '%s': %s\n",
|
av_log(NULL, AV_LOG_ERROR, "Error while reading file '%s': %s\n",
|
||||||
filename, strerror(errno));
|
filename, strerror(errno));
|
||||||
ret = AVERROR(errno);
|
|
||||||
} else
|
} else
|
||||||
ret = AVERROR_EOF;
|
ret = AVERROR_EOF;
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user