Skip to content

Commit 4564b8a

Browse files
authored
Merge pull request opencv#17841 from vpisarev:fixed_fs_dtor
* fixed issue opencv#17412 * Update test_io.cpp
1 parent 9b7b22e commit 4564b8a

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

modules/core/src/persistence.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1819,7 +1819,6 @@ void FileStorage::endWriteStruct()
18191819

18201820
FileStorage::~FileStorage()
18211821
{
1822-
p.release();
18231822
}
18241823

18251824
bool FileStorage::open(const String& filename, int flags, const String& encoding)

modules/core/test/test_io.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,4 +1772,20 @@ TEST(Core_InputOutput, FileStorage_open_empty_16823)
17721772
EXPECT_EQ(0, remove(fname.c_str()));
17731773
}
17741774

1775+
TEST(Core_InputOutput, FileStorage_copy_constructor_17412)
1776+
{
1777+
std::string fname = tempfile("test.yml");
1778+
FileStorage fs_orig(fname, cv::FileStorage::WRITE);
1779+
fs_orig << "string" << "wat";
1780+
fs_orig.release();
1781+
1782+
// no crash anymore
1783+
cv::FileStorage fs;
1784+
fs = cv::FileStorage(fname, cv::FileStorage::READ);
1785+
std::string s;
1786+
fs["string"] >> s;
1787+
EXPECT_EQ(s, "wat");
1788+
EXPECT_EQ(0, remove(fname.c_str()));
1789+
}
1790+
17751791
}} // namespace

0 commit comments

Comments
 (0)