From b6ad06faa2e0da4a7248f57fc63ae838847e51bd Mon Sep 17 00:00:00 2001 From: Marius Kittler Date: Tue, 25 Jun 2019 11:36:47 +0200 Subject: [PATCH] Do not close file if not opened in PasswordFile::save() --- io/passwordfile.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/io/passwordfile.cpp b/io/passwordfile.cpp index 97aae51..22d8b0c 100644 --- a/io/passwordfile.cpp +++ b/io/passwordfile.cpp @@ -401,8 +401,10 @@ void PasswordFile::save(PasswordFileSaveFlags options) if (m_file.good() && m_file.is_open() && (m_file.flags() & ios_base::out)) { m_file.seekp(0); } else { - m_file.close(); m_file.clear(); + if (m_file.is_open()) { + m_file.close(); + } m_file.open(m_path, ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary); }