1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

rtmp: Don't try to do av_malloc(0)

Some received packets can have size 0. The return value from
av_malloc(0) may be NULL, which is ok if the size was 0. On
OS X, however, the returned pointer is non-null but leads to
crashes when trying to free it.

Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
Martin Storsjö 2011-05-25 19:08:29 +03:00
parent 67540af7ba
commit 271c869cc3
2 changed files with 3 additions and 1 deletions

View File

@ -233,9 +233,11 @@ int ff_rtmp_packet_write(URLContext *h, RTMPPacket *pkt,
int ff_rtmp_packet_create(RTMPPacket *pkt, int channel_id, RTMPPacketType type, int ff_rtmp_packet_create(RTMPPacket *pkt, int channel_id, RTMPPacketType type,
int timestamp, int size) int timestamp, int size)
{ {
if (size) {
pkt->data = av_malloc(size); pkt->data = av_malloc(size);
if (!pkt->data) if (!pkt->data)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
}
pkt->data_size = size; pkt->data_size = size;
pkt->channel_id = channel_id; pkt->channel_id = channel_id;
pkt->type = type; pkt->type = type;

View File

@ -683,7 +683,7 @@ static int get_packet(URLContext *s, int for_header)
return AVERROR_EOF; return AVERROR_EOF;
for (;;) { for (;;) {
RTMPPacket rpkt; RTMPPacket rpkt = { 0 };
if ((ret = ff_rtmp_packet_read(rt->stream, &rpkt, if ((ret = ff_rtmp_packet_read(rt->stream, &rpkt,
rt->chunk_size, rt->prev_pkt[0])) <= 0) { rt->chunk_size, rt->prev_pkt[0])) <= 0) {
if (ret == 0) { if (ret == 0) {