Fix crash when execing invalid RPC
When executing an invalid RPC, the temporary datastore wasn't being
properly canceled.
Issue: https://tree.taiga.io/project/jktjkt-netconf-cli/issue/209
Change-Id: I56e301c509781275bd960f4cd846d649507a875d
diff --git a/src/proxy_datastore.cpp b/src/proxy_datastore.cpp
index f212d45..8f86831 100644
--- a/src/proxy_datastore.cpp
+++ b/src/proxy_datastore.cpp
@@ -5,6 +5,7 @@
*
*/
#include <boost/algorithm/string/predicate.hpp>
+#include "UniqueResource.hpp"
#include "proxy_datastore.hpp"
#include "yang_schema.hpp"
@@ -74,10 +75,10 @@
if (!m_inputDatastore) {
throw std::runtime_error("No RPC/action input in progress");
}
+ auto cancelOnReturn = make_unique_resource([] {}, [this] { cancel(); });
auto inputData = m_inputDatastore->getItems("/");
auto out = m_datastore->execute(*m_inputPath, inputData);
- cancel();
return out;
}