Commit 9552eb6b01 for ffmpeg
commit 9552eb6b01711ece77a7f2e6166e7a47673baefa
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Fri Nov 6 03:59:29 2026 +0100
avfilter/vf_selectivecolor: unmap the psfile with the mapped pointer and size
Fixes: xFNgu3kY8YOa
Found during review of the fix for the security report urb6qL5xnaVD
The same fix for vf_curves is in PR #25298 by Martin Mirchev.
Leaked file mapping Replicated through UnModified FFmpeg with strace
diff --git a/libavfilter/vf_selectivecolor.c b/libavfilter/vf_selectivecolor.c
index 6d27bdacb0..2da97dfd4b 100644
--- a/libavfilter/vf_selectivecolor.c
+++ b/libavfilter/vf_selectivecolor.c
@@ -186,13 +186,15 @@ static int parse_psfile(AVFilterContext *ctx, const char *fname)
{
int16_t val;
int ret, i, version;
- uint8_t *buf;
- size_t size;
+ uint8_t *map, *buf;
+ size_t map_size, size;
SelectiveColorContext *s = ctx->priv;
- ret = av_file_map(fname, &buf, &size, 0, NULL);
+ ret = av_file_map(fname, &map, &map_size, 0, NULL);
if (ret < 0)
return ret;
+ buf = map;
+ size = map_size;
#define READ16(dst) do { \
if (size < 2) { \
@@ -235,7 +237,7 @@ static int parse_psfile(AVFilterContext *ctx, const char *fname)
}
end:
- av_file_unmap(buf, size);
+ av_file_unmap(map, map_size);
return ret;
}