aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2024-07-23 15:11:08 +0200
committerAnton Khirnov <anton@khirnov.net>2024-07-24 08:20:21 +0200
commitd1fa39d08d3bce9c268cd02cb3c45a76e63b6ff4 (patch)
tree7ddb31ab91301a53fd3ae4010ad5c327b90d0623
parentb1b69ccbc0b2043e60b95735acced292413c44a5 (diff)
downloadffmpeg-d1fa39d08d3bce9c268cd02cb3c45a76e63b6ff4.tar.gz
fftools/ffmpeg: prefer real errors over EOF in err_merge()
Fixes an issue in 6.1 when reading a corrupted file with -xerror would exit with success. This specific issue is not present in master, but this should generally be a more robust behaviour. Reported-by: Andrej Peterka
-rw-r--r--fftools/ffmpeg_utils.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/fftools/ffmpeg_utils.h b/fftools/ffmpeg_utils.h
index bd225abc38..7939e44cdc 100644
--- a/fftools/ffmpeg_utils.h
+++ b/fftools/ffmpeg_utils.h
@@ -35,11 +35,12 @@ typedef struct Timestamp {
/**
* Merge two return codes - return one of the error codes if at least one of
* them was negative, 0 otherwise.
- * Currently just picks the first one, eventually we might want to do something
- * more sophisticated, like sorting them by priority.
*/
static inline int err_merge(int err0, int err1)
{
+ // prefer "real" errors over EOF
+ if ((err0 >= 0 || err0 == AVERROR_EOF) && err1 < 0)
+ return err1;
return (err0 < 0) ? err0 : FFMIN(err1, 0);
}