Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed an out of bounds error, where an empty array wasn't being prope…

…rly interpreted.
  • Loading branch information...
commit f7ad2a4918270615e6dcc122db9379d2cc9010aa 1 parent 8192833
Rosangela Canino-Koning authored
View
4 Caper/BundleFileEngine.h
@@ -26,8 +26,8 @@ class BundleFileEngine :
MappingIndex::mapped_type::iterator lWindowIterator = lContigIterator->second.find(aWindowNumber);
- if ( lWindowIterator == lContigIterator->second.end() )
- return NULL;
+ if ( lWindowIterator == lContigIterator->second.end() ) // non-existent window!
+ return new vector<Mapping *>();
char * lBlock = ReadBlock( lWindowIterator->second.BlockOffset, lWindowIterator->second.CompressedBlockSizeInBytes );
View
2  Caper/MappingCache.h
@@ -33,7 +33,7 @@ class MappingCache
ReadsAtIndex * GetReads( long long aIndex ) // this could possibly be empty.
{
//cout << "~~MappingCache - GetReads" << endl;
- if ( mCachedIterator->first != aIndex )
+ if ( mCachedIterator == mMappings.end() || mCachedIterator->first != aIndex ) // we're not anywhere, or we don't match up, try to find it.
mCachedIterator = mMappings.find( aIndex );
if ( mCachedIterator == mMappings.end() ) // empty! Likely we addressed an index that doesn't have an entry. This is fine.
View
8 Caper/MappingCacheFactory.h
@@ -21,12 +21,8 @@ class MappingCacheFactory
MappingCache * BuildMappingCache( string & aContig, long long aWindowNumber )
{
// cout << "~~MappingCacheFactory - BuildMappingCache " << aContig << " window " << aWindowNumber << endl;
- vector<Mapping*> * lMappings = mFileEngine->FetchMappings( aContig, aWindowNumber );
-
-// cout << "~~MappingCacheFactory - BuildMappingCache " << aContig << " window " << aWindowNumber << endl;
- if ( lMappings == NULL ) // no window!
- return NULL;
-
+ vector<Mapping*> * lMappings = mFileEngine->FetchMappings( aContig, aWindowNumber );
+
long long aLeft = aWindowNumber * IndexIncrement;
long long aRight = ( aWindowNumber * IndexIncrement ) + IndexIncrement - 1;
MappingCache * lCache = new MappingCache( aContig, aLeft, aRight );
View
2  Caper/MappingFileEngine.h
@@ -184,7 +184,7 @@ class MappingFileEngine
MappingIndex::mapped_type::iterator lWindowIterator = lContigIterator->second.find(aWindowNumber);
if ( lWindowIterator == lContigIterator->second.end() ) // non-existent window!
- return NULL;
+ return new vector<Mapping *>();
char * lBlock = new char[ lWindowIterator->second.BlockSizeInBytes + 1 ];
ReadBlock( lWindowIterator->second.BlockOffset, lWindowIterator->second.CompressedBlockSizeInBytes );
Please sign in to comment.
Something went wrong with that request. Please try again.