Merge pull request #17841 from vpisarev:fixed_fs_dtor

* fixed issue #17412

* Update test_io.cpp
This commit is contained in:
Vadim Pisarevsky 2020-07-17 05:28:50 +03:00 committed by GitHub
parent 9b7b22ee0e
commit 4564b8a224
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -1819,7 +1819,6 @@ void FileStorage::endWriteStruct()
FileStorage::~FileStorage()
{
p.release();
}
bool FileStorage::open(const String& filename, int flags, const String& encoding)

View File

@ -1772,4 +1772,20 @@ TEST(Core_InputOutput, FileStorage_open_empty_16823)
EXPECT_EQ(0, remove(fname.c_str()));
}
TEST(Core_InputOutput, FileStorage_copy_constructor_17412)
{
std::string fname = tempfile("test.yml");
FileStorage fs_orig(fname, cv::FileStorage::WRITE);
fs_orig << "string" << "wat";
fs_orig.release();
// no crash anymore
cv::FileStorage fs;
fs = cv::FileStorage(fname, cv::FileStorage::READ);
std::string s;
fs["string"] >> s;
EXPECT_EQ(s, "wat");
EXPECT_EQ(0, remove(fname.c_str()));
}
}} // namespace