mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 00:03:03 +04:00
core: fix persistence bug in RAW I/O code
- persistence.cpp code expects special sizeof value for passed structures - this assumption is lead to memory corruption problems - fixed/workarounded test to prevent memory corruption on Linux 32-bit systems
This commit is contained in:
@@ -4907,7 +4907,7 @@ cvReadRawDataSlice( const CvFileStorage* fs, CvSeqReader* reader,
|
||||
{
|
||||
char* data0 = (char*)_data;
|
||||
int fmt_pairs[CV_FS_MAX_FMT_PAIRS*2], k = 0, fmt_pair_count;
|
||||
int i = 0, offset = 0, count = 0;
|
||||
int i = 0, count = 0;
|
||||
|
||||
CV_CHECK_FILE_STORAGE( fs );
|
||||
|
||||
@@ -4918,9 +4918,11 @@ cvReadRawDataSlice( const CvFileStorage* fs, CvSeqReader* reader,
|
||||
CV_Error( CV_StsBadSize, "The readed sequence is a scalar, thus len must be 1" );
|
||||
|
||||
fmt_pair_count = icvDecodeFormat( dt, fmt_pairs, CV_FS_MAX_FMT_PAIRS );
|
||||
size_t step = ::icvCalcStructSize(dt, 0);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
int offset = 0;
|
||||
for( k = 0; k < fmt_pair_count; k++ )
|
||||
{
|
||||
int elem_type = fmt_pairs[k*2+1];
|
||||
@@ -5038,6 +5040,7 @@ cvReadRawDataSlice( const CvFileStorage* fs, CvSeqReader* reader,
|
||||
|
||||
offset = (int)(data - data0);
|
||||
}
|
||||
data0 += step;
|
||||
}
|
||||
|
||||
end_loop:
|
||||
|
||||
Reference in New Issue
Block a user