[FFmpeg-cvslog] r20899 - trunk/libavcodec/xan.c

kostya subversion
Sat Dec 19 18:04:30 CET 2009


Author: kostya
Date: Sat Dec 19 18:04:30 2009
New Revision: 20899

Log:
Improve handling allocated buffers in Xan decoder

Modified:
   trunk/libavcodec/xan.c

Modified: trunk/libavcodec/xan.c
==============================================================================
--- trunk/libavcodec/xan.c	Sat Dec 19 17:39:21 2009	(r20898)
+++ trunk/libavcodec/xan.c	Sat Dec 19 18:04:30 2009	(r20899)
@@ -76,10 +76,14 @@ static av_cold int xan_decode_init(AVCod
 
     s->buffer1_size = avctx->width * avctx->height;
     s->buffer1 = av_malloc(s->buffer1_size);
+    if (!s->buffer1)
+        return -1;
     s->buffer2_size = avctx->width * avctx->height;
     s->buffer2 = av_malloc(s->buffer2_size + 130);
-    if (!s->buffer1 || !s->buffer2)
+    if (!s->buffer2) {
+        av_freep(&s->buffer1);
         return -1;
+    }
 
     return 0;
 }
@@ -405,8 +409,8 @@ static av_cold int xan_decode_end(AVCode
     if (s->current_frame.data[0])
         avctx->release_buffer(avctx, &s->current_frame);
 
-    av_free(s->buffer1);
-    av_free(s->buffer2);
+    av_freep(&s->buffer1);
+    av_freep(&s->buffer2);
 
     return 0;
 }



More information about the ffmpeg-cvslog mailing list