diff options
author | Marton Balint <cus@passwd.hu> | 2019-08-05 22:27:47 +0200 |
---|---|---|
committer | Marton Balint <cus@passwd.hu> | 2019-08-17 18:39:49 +0200 |
commit | 95fa73a2b48fe8e73fb2b25d3b272da1bbd167b3 (patch) | |
tree | f5e49d23de3b4f00227c7763139b2066bdf2528e /libavformat/aviobuf.c | |
parent | 61b4daf78ce09534b258aae6b86934ce98d2b27f (diff) | |
download | ffmpeg-95fa73a2b48fe8e73fb2b25d3b272da1bbd167b3.tar.gz |
avformat/avio: remove 4k limit from avio_printf
We do this by switching to AVBPrint.
v2: Also set IO context error flag in case of ENOMEM.
Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavformat/aviobuf.c')
-rw-r--r-- | libavformat/aviobuf.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 85d809c6cd..2dfce8af8b 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -1249,14 +1249,20 @@ int avio_closep(AVIOContext **s) int avio_printf(AVIOContext *s, const char *fmt, ...) { va_list ap; - char buf[4096]; /* update doc entry in avio.h if changed */ - int ret; + AVBPrint bp; + av_bprint_init(&bp, 0, INT_MAX); va_start(ap, fmt); - ret = vsnprintf(buf, sizeof(buf), fmt, ap); + av_vbprintf(&bp, fmt, ap); va_end(ap); - avio_write(s, buf, strlen(buf)); - return ret; + if (!av_bprint_is_complete(&bp)) { + av_bprint_finalize(&bp, NULL); + s->error = AVERROR(ENOMEM); + return AVERROR(ENOMEM); + } + avio_write(s, bp.str, bp.len); + av_bprint_finalize(&bp, NULL); + return bp.len; } void avio_print_string_array(AVIOContext *s, const char *strings[]) |