[xiph-commits] r9315 - trunk/speex/libspeex

jm at motherfish-iii.xiph.org jm at motherfish-iii.xiph.org
Wed May 25 21:09:23 PDT 2005


Author: jm
Date: 2005-05-25 21:09:21 -0700 (Wed, 25 May 2005)
New Revision: 9315

Modified:
   trunk/speex/libspeex/nb_celp.c
   trunk/speex/libspeex/sb_celp.c
Log:
Better check for memory allocation failure


Modified: trunk/speex/libspeex/nb_celp.c
===================================================================
--- trunk/speex/libspeex/nb_celp.c	2005-05-26 03:04:48 UTC (rev 9314)
+++ trunk/speex/libspeex/nb_celp.c	2005-05-26 04:09:21 UTC (rev 9315)
@@ -97,13 +97,15 @@
    mode=(const SpeexNBMode *)m->mode;
 #if defined(VAR_ARRAYS) || defined (USE_ALLOCA)
    st = (EncState*)speex_alloc(sizeof(EncState));
+   if (!st)
+      return NULL;
    st->stack = NULL;
 #else
    st = (EncState*)speex_alloc(sizeof(EncState)+8000*sizeof(spx_sig_t));
+   if (!st)
+      return NULL;
    st->stack = ((char*)st) + sizeof(EncState);
 #endif
-   if (!st)
-      return NULL;
    
    st->mode=m;
 
@@ -937,13 +939,15 @@
    mode=(const SpeexNBMode*)m->mode;
 #if defined(VAR_ARRAYS) || defined (USE_ALLOCA)
    st = (DecState *)speex_alloc(sizeof(DecState));
+   if (!st)
+      return NULL;
    st->stack = NULL;
 #else
    st = (DecState *)speex_alloc(sizeof(DecState)+4000*sizeof(spx_sig_t));
+   if (!st)
+      return NULL;
    st->stack = ((char*)st) + sizeof(DecState);
 #endif
-   if (!st)
-      return NULL;
 
    st->mode=m;
 

Modified: trunk/speex/libspeex/sb_celp.c
===================================================================
--- trunk/speex/libspeex/sb_celp.c	2005-05-26 03:04:48 UTC (rev 9314)
+++ trunk/speex/libspeex/sb_celp.c	2005-05-26 04:09:21 UTC (rev 9315)
@@ -218,13 +218,15 @@
 
 #if defined(VAR_ARRAYS) || defined (USE_ALLOCA)
    st = (SBEncState*)speex_alloc(sizeof(SBEncState));
+   if (!st)
+      return NULL;
    st->stack = NULL;
 #else
    st = (SBEncState*)speex_alloc(sizeof(SBEncState)+10000*sizeof(spx_sig_t));
+   if (!st)
+      return NULL;
    st->stack = ((char*)st) + sizeof(SBEncState);
 #endif
-   if (!st)
-      return NULL;
    st->mode = m;
    mode = (const SpeexSBMode*)m->mode;
 
@@ -785,13 +787,15 @@
    const SpeexSBMode *mode;
 #if defined(VAR_ARRAYS) || defined (USE_ALLOCA)
    st = (SBDecState*)speex_alloc(sizeof(SBDecState));
+   if (!st)
+      return NULL;
    st->stack = NULL;
 #else   
    st = (SBDecState*)speex_alloc(sizeof(SBDecState)+6000*sizeof(spx_sig_t));
+   if (!st)
+      return NULL;
    st->stack = ((char*)st) + sizeof(SBDecState);
 #endif
-   if (!st)
-      return NULL;
    st->mode = m;
    mode=(const SpeexSBMode*)m->mode;
 



More information about the commits mailing list