common: ++exception handling.
authorHermet Park <chuneon.park@samsung.com>
Fri, 5 Nov 2021 12:04:51 +0000 (21:04 +0900)
committerJunsuChoi <jsuya.choi@samsung.com>
Wed, 10 Nov 2021 01:43:08 +0000 (10:43 +0900)
fix the memory leak in the corner case

detected by tvg test suites

@Issue: https://github.com/Samsung/thorvg/issues/995

src/lib/tvgSaver.cpp

index ffa2bf1..dc240d0 100644 (file)
@@ -110,9 +110,12 @@ Result Saver::save(std::unique_ptr<Paint> paint, const string& path, bool compre
             pImpl->saveModule = saveModule;
             return Result::Success;
         } else {
+            delete(p);
+            delete(saveModule);
             return Result::Unknown;
         }
     }
+    delete(p);
     return Result::NonSupport;
 }