[xiph-commits] r18219 - trunk/theora/lib

tterribe at svn.xiph.org tterribe at svn.xiph.org
Fri Mar 2 15:38:16 PST 2012


Author: tterribe
Date: 2012-03-02 15:38:12 -0800 (Fri, 02 Mar 2012)
New Revision: 18219

Modified:
   trunk/theora/lib/internal.c
   trunk/theora/lib/state.c
Log:
Remove some redundant NULL checks and fix a free on error return.

ref_frame_data was being allocated with the aligned allocator, but
 freed with the normal _ogg_free() function on failure, which
 doesn't work.
This would only cause a problem if there was just enough memory to
 satisfy the reference frame allocation (just over 4.5 or 9 bytes
 per pixel) but not enough for the fragment buffer offets (1/16 or
 1/8th byte per pixel).


Modified: trunk/theora/lib/internal.c
===================================================================
--- trunk/theora/lib/internal.c	2012-03-02 21:36:29 UTC (rev 18218)
+++ trunk/theora/lib/internal.c	2012-03-02 23:38:12 UTC (rev 18219)
@@ -131,7 +131,6 @@
   datsz=rowsz*_height;
   /*Alloc array and row pointers.*/
   ret=(char *)_ogg_malloc(datsz+colsz);
-  if(ret==NULL)return NULL;
   /*Initialize the array.*/
   if(ret!=NULL){
     size_t   i;
@@ -154,7 +153,6 @@
   datsz=rowsz*_height;
   /*Alloc array and row pointers.*/
   ret=(char *)_ogg_calloc(datsz+colsz,1);
-  if(ret==NULL)return NULL;
   /*Initialize the array.*/
   if(ret!=NULL){
     size_t   i;

Modified: trunk/theora/lib/state.c
===================================================================
--- trunk/theora/lib/state.c	2012-03-02 21:36:29 UTC (rev 18218)
+++ trunk/theora/lib/state.c	2012-03-02 23:38:12 UTC (rev 18219)
@@ -588,7 +588,7 @@
    _ogg_malloc(_state->nfrags*sizeof(*frag_buf_offs));
   if(ref_frame_data==NULL||frag_buf_offs==NULL){
     _ogg_free(frag_buf_offs);
-    _ogg_free(ref_frame_data);
+    oc_aligned_free(ref_frame_data);
     return TH_EFAULT;
   }
   /*Set up the width, height and stride for the image buffers.*/



More information about the commits mailing list