ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinha...@gmail.com> | 
Wed Feb 12 13:27:17 2020 +0100| [8f51a89d66aacd9dc5896bac22e62cbd566e7a71] | 
committer: Andreas Rheinhardt

avcodec/avpacket: Don't write into non-writable buffer

The data of an AVPacket may be a part of the data of an AVBufferRef;
Therefore av_grow_packet() doesn't reallocate if the available space in
the actual buffer is sufficient for the enlargement. But given that it
also zeroes the padding it also needs to make sure that the buffer is
actually writable; this commit implements this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8f51a89d66aacd9dc5896bac22e62cbd566e7a71
---

 libavcodec/avpacket.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index 55b509108e..ee51c0799c 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -128,7 +128,8 @@ int av_grow_packet(AVPacket *pkt, int grow_by)
                 return AVERROR(ENOMEM);
         }
 
-        if (new_size + data_offset > pkt->buf->size) {
+        if (new_size + data_offset > pkt->buf->size ||
+            !av_buffer_is_writable(pkt->buf)) {
             int ret = av_buffer_realloc(&pkt->buf, new_size + data_offset);
             if (ret < 0) {
                 pkt->data = old_data;

_______________________________________________
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to