1
0
mirror of https://github.com/roytam1/UXP.git synced 2026-05-26 05:46:58 +00:00

[media] ffvpx patch: Fix leak in flac decoder in case of alloc failure.

This commit is contained in:
Moonchild
2026-05-25 19:10:46 +02:00
committed by roytam1
parent 2f73a3004b
commit 9afa7a80cc
3 changed files with 34 additions and 2 deletions
+5
View File
@@ -41,3 +41,8 @@ Run in the ffmpeg original tree:
$ for i in `cat $PATH_CENTRAL/media/ffvpx/FILES`; do diff $REV_LASTSYNC HEAD >> patch.diff; done
Then apply patch.diff on the ffvpx tree.
Compilation will reveal if any files are missing.
========================
After updating, apply patches:
flac-alloc-failure.patch fix leak in flac decoder in case of alloc failure
+25
View File
@@ -0,0 +1,25 @@
diff --git a/media/ffvpx/libavcodec/flacdec.c b/media/ffvpx/libavcodec/flacdec.c
index 3d41a1af7f..8189d6af53 100644
--- a/media/ffvpx/libavcodec/flacdec.c
+++ b/media/ffvpx/libavcodec/flacdec.c
@@ -146,8 +146,10 @@ static int allocate_buffers(FLACContext *s)
return buf_size;
av_fast_malloc(&s->decoded_buffer, &s->decoded_buffer_size, buf_size);
- if (!s->decoded_buffer)
+ if (!s->decoded_buffer) {
+ memset(s->decoded, 0, sizeof(s->decoded));
return AVERROR(ENOMEM);
+ }
ret = av_samples_fill_arrays((uint8_t **)s->decoded, NULL,
s->decoded_buffer,
@@ -525,7 +527,7 @@ static int decode_frame(FLACContext *s)
fi.samplerate = s->flac_stream_info.samplerate;
s->flac_stream_info.samplerate = s->avctx->sample_rate = fi.samplerate;
- if (!s->got_streaminfo) {
+ if (!s->got_streaminfo || !s->decoded_buffer) {
ret = allocate_buffers(s);
if (ret < 0)
return ret;
+4 -2
View File
@@ -146,8 +146,10 @@ static int allocate_buffers(FLACContext *s)
return buf_size;
av_fast_malloc(&s->decoded_buffer, &s->decoded_buffer_size, buf_size);
if (!s->decoded_buffer)
if (!s->decoded_buffer) {
memset(s->decoded, 0, sizeof(s->decoded));
return AVERROR(ENOMEM);
}
ret = av_samples_fill_arrays((uint8_t **)s->decoded, NULL,
s->decoded_buffer,
@@ -525,7 +527,7 @@ static int decode_frame(FLACContext *s)
fi.samplerate = s->flac_stream_info.samplerate;
s->flac_stream_info.samplerate = s->avctx->sample_rate = fi.samplerate;
if (!s->got_streaminfo) {
if (!s->got_streaminfo || !s->decoded_buffer) {
ret = allocate_buffers(s);
if (ret < 0)
return ret;