It ensures that the packet is properly padded and makes the code simpler. Fixes trac ticket #1223.
Unified · Split
| @@ -1126,12 +1126,10 @@ static void matroska_fix_ass_packet(MatroskaDemuxContext *matroska, · 1125 unmodified lines | |||
| 1126 | 1126 | ||
| 1127 | static int matroska_merge_packets(AVPacket *out, AVPacket *in) | 1127 | static int matroska_merge_packets(AVPacket *out, AVPacket *in) |
| 1128 | { | 1128 | { |
| 1129 | void *newdata = av_realloc(out->data, out->size+in->size); | 1129 | int ret = av_grow_packet(out, in->size); |
| 1130 | if (!newdata) | 1130 | if (ret < 0) |
| 1131 | return AVERROR(ENOMEM); | 1131 | return ret; |
| 1132 | out->data = newdata; | 1132 | memcpy(out->data + out->size - in->size, in->data, in->size); |
| 1133 | memcpy(out->data+out->size, in->data, in->size); | ||
| 1134 | out->size += in->size; | ||
| 1135 | av_destruct_packet(in); | 1133 | av_destruct_packet(in); |
| 1136 | av_free(in); | 1134 | av_free(in); |
| 1137 | return 0; | 1135 | return 0; |