changeset 10700:96a836b623ba libavcodec

Improve handling allocated buffers in Xan decoder
author kostya
date Sat, 19 Dec 2009 17:04:30 +0000
parents 633727ffa79a
children fb7d1f0e8bc6
files xan.c
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/xan.c	Sat Dec 19 16:39:21 2009 +0000
+++ b/xan.c	Sat Dec 19 17:04:30 2009 +0000
@@ -76,10 +76,14 @@
 
     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 @@
     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;
 }