martinzink commented on a change in pull request #1035:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1035#discussion_r597631623



##########
File path: nanofi/src/api/nanofi.cpp
##########
@@ -131,20 +131,26 @@ nifi_instance *create_instance_repo(const char *url, 
nifi_port *port, const char
   return instance;
 }
 
+nifi_instance * acquire_standalone_instance () {
+  if (standalone_instance == nullptr) {
+    nifi_port port;
+    auto port_str = 
utils::IdGenerator::getIdGenerator()->generate().to_string();
+    port.port_id = const_cast<char *>(port_str.c_str());
+    standalone_instance = create_instance("internal_standalone", &port);
+  }
+  return standalone_instance;
+}
+
 standalone_processor * create_processor(const char *name, nifi_instance * 
instance) {
   NULL_CHECK(nullptr, name);
   auto ptr = ExecutionPlan::createProcessor(name, name);
   if (!ptr) {
     return nullptr;
   }
-  if (instance == NULL) {
-    nifi_port port;
-    auto port_str = 
utils::IdGenerator::getIdGenerator()->generate().to_string();
-    port.port_id = const_cast<char*>(port_str.c_str());
-    instance = create_instance("internal_standalone", &port);
-  }
+  if (instance == nullptr)
+    instance = acquire_standalone_instance();
   auto flow = create_new_flow(instance);
-  std::shared_ptr<ExecutionPlan> plan(flow);
+  std::shared_ptr<ExecutionPlan> plan(flow, free_flow);

Review comment:
       This caused the mismatched malloc vs operator delete (which has 
undefined behavior)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to