From 3b5530fb677f3e3e0962b7fa3f0ea96c8857aa74 Mon Sep 17 00:00:00 2001 From: Boris Daskalov Date: Tue, 17 Mar 2015 16:23:03 +0200 Subject: [PATCH] Fix a bad free space check in icvGrowSeq. A difference of two pointers was casted to unsigned which can lead to overflow on 64-bit systems. --- modules/core/src/datastructs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/src/datastructs.cpp b/modules/core/src/datastructs.cpp index c0067f8fc4..519d00ee53 100644 --- a/modules/core/src/datastructs.cpp +++ b/modules/core/src/datastructs.cpp @@ -651,7 +651,7 @@ icvGrowSeq( CvSeq *seq, int in_front_of ) /* If there is a free space just after last allocated block and it is big enough then enlarge the last block. This can happen only if the new block is added to the end of sequence: */ - if( (unsigned)(ICV_FREE_PTR(storage) - seq->block_max) < CV_STRUCT_ALIGN && + if( (size_t)(ICV_FREE_PTR(storage) - seq->block_max) < CV_STRUCT_ALIGN && storage->free_space >= seq->elem_size && !in_front_of ) { int delta = storage->free_space / elem_size;