1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

Merge pull request #16488 from vpisarev:filestorage_longlines

trying to fix handling file storages with extremely long lines

* trying to fix handling of file storages with extremely long lines: https://github.com/opencv/opencv/issues/11061

* * fixed errorneous pointer access in JSON parser.
* it's now crash-test time! temporarily set the initial parser buffer size to just 40 bytes. let's run all the test and check if the buffer is always correctly resized and handled

* fixed pointer use in JSON parser; added the proper test to catch this case

* fixed the test to make it more challenging. generate test json with
*
**
***
etc. shape
This commit is contained in:
Vadim Pisarevsky
2020-02-11 18:46:15 +03:00
committed by GitHub
parent aa2777ed61
commit 3efa78311a
3 changed files with 103 additions and 66 deletions
+4 -8
View File
@@ -411,7 +411,10 @@ public:
if( *ptr != '"' )
CV_PARSE_ERROR_CPP( "Key must end with \'\"\'" );
const char * end = ptr;
if( ptr == beg )
CV_PARSE_ERROR_CPP( "Key is empty" );
value_placeholder = fs->addNode(collection, std::string(beg, (size_t)(ptr - beg)), FileNode::NONE);
ptr++;
ptr = skipSpaces( ptr );
if( !ptr || !*ptr )
@@ -420,11 +423,6 @@ public:
if( *ptr != ':' )
CV_PARSE_ERROR_CPP( "Missing \':\' between key and value" );
/* [beg, end) */
if( end <= beg )
CV_PARSE_ERROR_CPP( "Key is empty" );
value_placeholder = fs->addNode(collection, std::string(beg, (size_t)(end - beg)), FileNode::NONE);
return ++ptr;
}
@@ -768,8 +766,6 @@ public:
CV_PARSE_ERROR_CPP( "left-brace of top level is missing" );
}
if( !ptr || !*ptr )
CV_PARSE_ERROR_CPP( "Unexpected End-Of-File" );
return true;
}