aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/rtmppkt.c
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2011-05-25 19:08:29 +0300
committerMartin Storsjö <martin@martin.st>2011-05-25 22:00:42 +0300
commit271c869cc3285dac2b6f2663a87c70bf3ba2b04f (patch)
tree59ef573dc2fe17b41f8e36989b4c141353ab9f04 /libavformat/rtmppkt.c
parent67540af7baa5c4064753861be217ac8f7c8df997 (diff)
downloadffmpeg-271c869cc3285dac2b6f2663a87c70bf3ba2b04f.tar.gz
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>
Diffstat (limited to 'libavformat/rtmppkt.c')
-rw-r--r--libavformat/rtmppkt.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c
index 63b0628799..93790eb525 100644
--- a/libavformat/rtmppkt.c
+++ b/libavformat/rtmppkt.c
@@ -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 timestamp, int size)
{
+ if (size) {
pkt->data = av_malloc(size);
if (!pkt->data)
return AVERROR(ENOMEM);
+ }
pkt->data_size = size;
pkt->channel_id = channel_id;
pkt->type = type;