Make sure destructors don't throw 27/319627/1 accepted/tizen_unified accepted/tizen_unified_x tizen accepted/tizen/unified/20250217.155037 accepted/tizen/unified/x/20250221.042208
authorMichal Bloch <m.bloch@samsung.com>
Thu, 13 Feb 2025 19:06:19 +0000 (20:06 +0100)
committerMichal Bloch <m.bloch@samsung.com>
Thu, 13 Feb 2025 19:06:19 +0000 (20:06 +0100)
Change-Id: Ia4d3d2fa715708f04fded238305543640e78424a

src/livedumper/helpers.hpp

index f7f0cb5ce940987cedcd8f7046f19b6c20bb8349..59e850f070bbe9dd044cda6a22242f89322a7f98 100644 (file)
@@ -125,7 +125,16 @@ class Guardian {
  public:
        Guardian(const std::function<void()> &start, const std::function<void()> &end)
                                                                : m_start(start), m_end(end) { m_start(); }
-       ~Guardian() { m_end(); }
+       ~Guardian() {
+               try {
+                       m_end();
+               } catch (...) {
+                       /* Token catch just because this
+                        * is a destructor, which can't rethrow.
+                        * Ignore because we can rely on people
+                        * not to use stupid guard functions. */
+               }
+       }
 };
 
 bool fileExists(const std::string &path) {