From c8fd40b011af80f436ac4c954dcc048ce4bc4aa4 Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Thu, 21 Oct 2010 12:26:11 +0000 Subject: [PATCH] fixed ds-graphscan test to make sure that the memory block size is large enough to fit at least the graph header and the sequence block header (ticket 504) --- tests/cxcore/src/adatastruct.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/cxcore/src/adatastruct.cpp b/tests/cxcore/src/adatastruct.cpp index 74c9547d8..fbccab7b5 100644 --- a/tests/cxcore/src/adatastruct.cpp +++ b/tests/cxcore/src/adatastruct.cpp @@ -2009,7 +2009,7 @@ void CxCore_GraphTest::run( int ) struct_idx = iter = -1; t = cvTsRandReal(rng)*(max_log_storage_block_size - min_log_storage_block_size) + min_log_storage_block_size; int block_size = cvRound( exp(t * CV_LOG2) ); - block_size = MAX(block_size, (int)(sizeof(CvGraph) + sizeof(CvMemBlock))); + block_size = MAX(block_size, (int)(sizeof(CvGraph) + sizeof(CvMemBlock) + sizeof(CvSeqBlock))); storage = cvCreateMemStorage(block_size); @@ -2138,7 +2138,11 @@ void CxCore_GraphScanTest::run( int ) { struct_idx = iter = -1; t = cvTsRandReal(rng)*(max_log_storage_block_size - min_log_storage_block_size) + min_log_storage_block_size; - storage = cvCreateMemStorage( cvRound( exp(t * CV_LOG2) ) ); + int storage_blocksize = cvRound( exp(t * CV_LOG2) ); + storage_blocksize = MAX(storage_blocksize, (int)(sizeof(CvGraph) + sizeof(CvMemBlock) + sizeof(CvSeqBlock))); + storage_blocksize = MAX(storage_blocksize, (int)(sizeof(CvGraphEdge) + sizeof(CvMemBlock) + sizeof(CvSeqBlock))); + storage_blocksize = MAX(storage_blocksize, (int)(sizeof(CvGraphVtx) + sizeof(CvMemBlock) + sizeof(CvSeqBlock))); + storage = cvCreateMemStorage(storage_blocksize); if( gen == 0 ) {