[gnote] Fix crash in case of exception when creating manifest



commit 440ab468d628d5684bdde9597e296a9e9199a096
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sun Mar 22 17:17:12 2020 +0200

    Fix crash in case of exception when creating manifest

 src/synchronization/filesystemsyncserver.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/src/synchronization/filesystemsyncserver.cpp b/src/synchronization/filesystemsyncserver.cpp
index 59c90456..c4ce3416 100644
--- a/src/synchronization/filesystemsyncserver.cpp
+++ b/src/synchronization/filesystemsyncserver.cpp
@@ -308,13 +308,16 @@ bool FileSystemSyncServer::commit_sync_transaction()
       xml->close();
       Glib::ustring xml_content = xml->to_string();
       delete xml;
+      xml = nullptr;
       auto stream = manifest_file->create_file(Gio::FILE_CREATE_REPLACE_DESTINATION);
       stream->write(xml_content);
       stream->close();
     }
     catch(...) {
-      xml->close();
-      delete xml;
+      if(xml) {
+        xml->close();
+        delete xml;
+      }
       throw;
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]