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

jm at svn.xiph.org jm at svn.xiph.org
Mon Jun 18 20:31:28 PDT 2007


Author: jm
Date: 2007-06-18 20:31:27 -0700 (Mon, 18 Jun 2007)
New Revision: 13141

Modified:
   trunk/speex/libspeex/cb_search.c
Log:
Additional safety net to prevent NaNs in the encoder from causing a segfault
(as had happened with vorbis-psy)


Modified: trunk/speex/libspeex/cb_search.c
===================================================================
--- trunk/speex/libspeex/cb_search.c	2007-06-18 21:11:34 UTC (rev 13140)
+++ trunk/speex/libspeex/cb_search.c	2007-06-19 03:31:27 UTC (rev 13141)
@@ -359,7 +359,11 @@
       /*"erase" nbest list*/
       for (j=0;j<N;j++)
          ndist[j]=VERY_LARGE32;
-
+      /* This is not strictly necessary, but it provides an additonal safety 
+         to prevent crashes in case something goes wrong in the previous
+         steps (e.g. NaNs) */
+      for (j=0;j<N;j++)
+         best_nind[j] = best_ntarget[j] = 0;
       /*For all n-bests of previous subvector*/
       for (j=0;j<N;j++)
       {
@@ -397,6 +401,7 @@
                         best_nind[n] = best_nind[n-1];
                         best_ntarget[n] = best_ntarget[n-1];
                      }
+                     /* n is equal to m here, so they're interchangeable */
                      ndist[m] = err;
                      best_nind[n] = best_index[k];
                      best_ntarget[n] = j;



More information about the commits mailing list