mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
core: added checks and "fixit" items for persistence parsers
To raise errors with proper messages of the problems.
This commit is contained in:
@@ -59,16 +59,33 @@ char* icvGets( CvFileStorage* fs, char* str, int maxCount )
|
||||
}
|
||||
str[j++] = '\0';
|
||||
fs->strbufpos = i;
|
||||
if (maxCount > 256)
|
||||
CV_Assert(j < maxCount - 1 && "OpenCV persistence doesn't support very long lines");
|
||||
return j > 1 ? str : 0;
|
||||
}
|
||||
if( fs->file )
|
||||
return fgets( str, maxCount, fs->file );
|
||||
{
|
||||
char* ptr = fgets( str, maxCount, fs->file );
|
||||
if (ptr && maxCount > 256)
|
||||
{
|
||||
size_t sz = strnlen(ptr, maxCount);
|
||||
CV_Assert(sz < (size_t)(maxCount - 1) && "OpenCV persistence doesn't support very long lines");
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
#if USE_ZLIB
|
||||
if( fs->gzfile )
|
||||
return gzgets( fs->gzfile, str, maxCount );
|
||||
{
|
||||
char* ptr = gzgets( fs->gzfile, str, maxCount );
|
||||
if (ptr && maxCount > 256)
|
||||
{
|
||||
size_t sz = strnlen(ptr, maxCount);
|
||||
CV_Assert(sz < (size_t)(maxCount - 1) && "OpenCV persistence doesn't support very long lines");
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
#endif
|
||||
CV_Error( CV_StsError, "The storage is not opened" );
|
||||
return 0;
|
||||
CV_ErrorNoReturn(CV_StsError, "The storage is not opened");
|
||||
}
|
||||
|
||||
int icvEof( CvFileStorage* fs )
|
||||
|
||||
Reference in New Issue
Block a user