[FFmpeg-devel] [PATCH 1/5] avformat/aviobuf: set AVIOContext->error on bprint buffer ENOMEM
Marton Balint
cus at passwd.hu
Mon Dec 27 02:26:09 EET 2021
This makes sure the error condition is kept in AVIOContext even if the user
does not check the return value of avio_read_to_bprint or
ff_read_line_to_bprint.
Signed-off-by: Marton Balint <cus at passwd.hu>
---
libavformat/aviobuf.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 29d4bd7510..6f8a822ee3 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -875,8 +875,10 @@ static int64_t read_string_to_bprint_overwrite(AVIOContext *s, AVBPrint *bp,
if (ret < 0)
return ret;
- if (!av_bprint_is_complete(bp))
+ if (!av_bprint_is_complete(bp)) {
+ s->error = AVERROR(ENOMEM);
return AVERROR(ENOMEM);
+ }
return bp->len;
}
@@ -1351,8 +1353,10 @@ int avio_read_to_bprint(AVIOContext *h, AVBPrint *pb, size_t max_size)
if (ret <= 0)
return ret;
av_bprint_append_data(pb, buf, ret);
- if (!av_bprint_is_complete(pb))
+ if (!av_bprint_is_complete(pb)) {
+ h->error = AVERROR(ENOMEM);
return AVERROR(ENOMEM);
+ }
max_size -= ret;
}
return 0;
--
2.31.1
More information about the ffmpeg-devel
mailing list