Revision a08d918e libavcodec/avpacket.c

View differences:

libavcodec/avpacket.c
20 20
 */
21 21

  
22 22
#include "avcodec.h"
23
#include "libavutil/avassert.h"
23 24

  
24 25

  
25 26
void av_destruct_packet_nofree(AVPacket *pkt)
......
71 72
    memset(pkt->data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
72 73
}
73 74

  
75
int av_grow_packet(AVPacket *pkt, int grow_by)
76
{
77
    void *new_ptr;
78
    av_assert0((unsigned)pkt->size <= INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE);
79
    if (!pkt->size)
80
        return av_new_packet(pkt, grow_by);
81
    if ((unsigned)grow_by > INT_MAX - (pkt->size + FF_INPUT_BUFFER_PADDING_SIZE))
82
        return -1;
83
    new_ptr = av_realloc(pkt->data, pkt->size + grow_by + FF_INPUT_BUFFER_PADDING_SIZE);
84
    if (!new_ptr)
85
        return AVERROR(ENOMEM);
86
    pkt->data = new_ptr;
87
    pkt->size += grow_by;
88
    memset(pkt->data + pkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
89
    return 0;
90
}
91

  
74 92
int av_dup_packet(AVPacket *pkt)
75 93
{
76 94
    if (((pkt->destruct == av_destruct_packet_nofree) || (pkt->destruct == NULL)) && pkt->data) {

Also available in: Unified diff