[FFmpeg-devel] [PATCH] avformat/concat: finalize the AVBprint buffer immediately
Marton Balint
cus at passwd.hu
Tue Jul 27 00:49:17 EEST 2021
On Mon, 26 Jul 2021, James Almer wrote:
> Don't attempt to read its contents in place.
> Fixes invalid reads when run under Valgrind.
As far as I remember AVBPrint buffer CAN be read in place by design,
zero terminator is always guaranteed, not only after finalizing. So this
should not be needed. What is causing the invalid reads exactly?
Thanks,
Marton
>
> 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
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>
More information about the ffmpeg-devel
mailing list