mirror of https://git.ffmpeg.org/ffmpeg.git
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.rheinhardt@gmail.com>
This commit is contained in:
parent
09bac9009e
commit
8f51a89d66
|
@ -128,7 +128,8 @@ int av_grow_packet(AVPacket *pkt, int grow_by)
|
||||||
return AVERROR(ENOMEM);
|
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);
|
int ret = av_buffer_realloc(&pkt->buf, new_size + data_offset);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
pkt->data = old_data;
|
pkt->data = old_data;
|
||||||
|
|
Loading…
Reference in New Issue