[FFmpeg-cvslog] r20801 - trunk/libavcodec/avpacket.c

michael subversion
Fri Dec 11 22:49:30 CET 2009


Author: michael
Date: Fri Dec 11 22:49:30 2009
New Revision: 20801

Log:
Make sure av_new_packet() initializes the data and destruct pointers.
Some code does call av_free_packet() on failed av_new_packets(), this
prevents the freeing of uninitialized pointers.

Modified:
   trunk/libavcodec/avpacket.c

Modified: trunk/libavcodec/avpacket.c
==============================================================================
--- trunk/libavcodec/avpacket.c	Fri Dec 11 21:02:10 2009	(r20800)
+++ trunk/libavcodec/avpacket.c	Fri Dec 11 22:49:30 2009	(r20801)
@@ -47,18 +47,20 @@ void av_init_packet(AVPacket *pkt)
 
 int av_new_packet(AVPacket *pkt, int size)
 {
-    uint8_t *data;
-    if((unsigned)size > (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
-        return AVERROR(ENOMEM);
+    uint8_t *data= NULL;
+    if((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
     data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
-    if (!data)
-        return AVERROR(ENOMEM);
+    if (data){
     memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+    }else
+        size=0;
 
     av_init_packet(pkt);
     pkt->data = data;
     pkt->size = size;
     pkt->destruct = av_destruct_packet;
+    if(!data)
+        return AVERROR(ENOMEM);
     return 0;
 }
 



More information about the ffmpeg-cvslog mailing list