From 25c490ecb64a90631fae0177829c1cfbef3a8c66 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Mon, 9 Nov 2015 12:33:37 +0100 Subject: [PATCH] Remove config file when object creation fails fixes #10578 --- lib/remote/configobjectutility.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/remote/configobjectutility.cpp b/lib/remote/configobjectutility.cpp index a114ef52c..91b525aa6 100644 --- a/lib/remote/configobjectutility.cpp +++ b/lib/remote/configobjectutility.cpp @@ -113,6 +113,8 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full if (!ConfigItem::CommitItems(upq) || !ConfigItem::ActivateItems(upq, false, true)) { if (errors) { + unlink(path.CStr()); + BOOST_FOREACH(const boost::exception_ptr& ex, upq.GetExceptions()) { errors->Add(DiagnosticInformation(ex)); } @@ -123,6 +125,8 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full } catch (const std::exception& ex) { delete expr; + unlink(path.CStr()); + if (errors) errors->Add(DiagnosticInformation(ex));