[FFmpeg-devel] [PATCH] avformat/concat: finalize the AVBprint buffer immediately
James Almer
jamrial at gmail.com
Mon Jul 26 16:05:06 EEST 2021
Don't attempt to read its contents in place.
Fixes invalid reads when run under Valgrind.
Signed-off-by: James Almer <jamrial at gmail.com>
---
libavformat/concat.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/libavformat/concat.c b/libavformat/concat.c
index aec1f52d8e..64ac03e1d8 100644
--- a/libavformat/concat.c
+++ b/libavformat/concat.c
@@ -211,6 +211,7 @@ static av_cold int concatf_open(URLContext *h, const char *uri, int flags)
struct concat_data *data = h->priv_data;
AVIOContext *in = NULL;
const char *cursor;
+ char *buf;
int64_t total_size = 0;
unsigned int nodes_size = 0;
size_t i = 0;
@@ -238,7 +239,11 @@ static av_cold int concatf_open(URLContext *h, const char *uri, int flags)
return err;
}
- cursor = bp.str;
+ err = av_bprint_finalize(&bp, &buf);
+ if (err < 0)
+ return err;
+
+ cursor = buf;
while (*cursor) {
struct concat_nodes *nodes;
URLContext *uc;
@@ -286,7 +291,7 @@ static av_cold int concatf_open(URLContext *h, const char *uri, int flags)
data->nodes[i++].size = size;
total_size += size;
}
- av_bprint_finalize(&bp, NULL);
+ av_free(buf);
data->length = i;
if (err < 0)
--
2.32.0
More information about the ffmpeg-devel
mailing list