changeset 188:0caa733d48c5 no-big-mmap

Test against running off the end of the timesTable properly.
author mas01cr
date Fri, 16 Nov 2007 16:39:59 +0000
parents 530154ca4cf5
children 0280c3f57b6f
files audioDB.cpp
diffstat 1 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/audioDB.cpp	Fri Nov 16 16:31:36 2007 +0000
+++ b/audioDB.cpp	Fri Nov 16 16:39:59 2007 +0000
@@ -599,11 +599,11 @@
   // Check times status and insert times from file
   unsigned timesoffset=insertoffset/(dbH->dim*sizeof(double));
   double* timesdata=timesTable+timesoffset;
-  /* FIXME: work out how to check against wandering off the end of the
-     times table.
 
-     assert(timesdata+numVectors<l2normTable);
-  */
+  if(timesoffset + numVectors > timesTableLength) {
+    error("out of space for times", key);
+  }
+    
   insertTimeStamps(numVectors, timesFile, timesdata);
 
   // Increment file count
@@ -765,7 +765,9 @@
 	  unsigned insertoffset=dbH->length;
 	  unsigned timesoffset=insertoffset/(dbH->dim*sizeof(double));
 	  double* timesdata=timesTable+timesoffset;
-	  assert(timesdata+numVectors<l2normTable);
+          if(timesoffset + numVectors > timesTableLength) {
+            error("out of space for times", key);
+          }
 	  insertTimeStamps(numVectors,thisTimesFile,timesdata);
 	  if(thisTimesFile)
 	    delete thisTimesFile;