diff --git a/libavcodec/cbs_h264_syntax_template.c b/libavcodec/cbs_h264_syntax_template.c index 106da0630e..1c8d7d5eae 100644 --- a/libavcodec/cbs_h264_syntax_template.c +++ b/libavcodec/cbs_h264_syntax_template.c @@ -725,7 +725,7 @@ static int FUNC(sei_user_data_registered)(CodedBitstreamContext *ctx, RWContext *payload_size = i + current->data_length; #endif - allocate(current->data, current->data_length); + allocate(current->data, current->data_length + AV_INPUT_BUFFER_PADDING_SIZE); for (j = 0; j < current->data_length; j++) xu(8, itu_t_t35_payload_byte[i], current->data[j], 0x00, 0xff, 1, i + j); diff --git a/libavcodec/cbs_mpeg2_syntax_template.c b/libavcodec/cbs_mpeg2_syntax_template.c index 8b5d35437e..88cf453b17 100644 --- a/libavcodec/cbs_mpeg2_syntax_template.c +++ b/libavcodec/cbs_mpeg2_syntax_template.c @@ -71,7 +71,7 @@ static int FUNC(user_data)(CodedBitstreamContext *ctx, RWContext *rw, av_assert0(k % 8 == 0); current->user_data_length = k /= 8; if (k > 0) { - current->user_data_ref = av_buffer_alloc(k); + current->user_data_ref = av_buffer_allocz(k + AV_INPUT_BUFFER_PADDING_SIZE); if (!current->user_data_ref) return AVERROR(ENOMEM); current->user_data = current->user_data_ref->data;