Browse Source

Fix double-free during saving on non-jack drivers

tags/1.9.4
falkTX 10 years ago
parent
commit
7f0ca7074a
3 changed files with 10 additions and 17 deletions
  1. +1
    -0
      source/backend/CarlaEngine.hpp
  2. +0
    -3
      source/backend/engine/CarlaEngine.cpp
  3. +9
    -14
      source/backend/engine/CarlaEngineJack.cpp

+ 1
- 0
source/backend/CarlaEngine.hpp View File

@@ -1089,6 +1089,7 @@ protected:

/*!
* Virtual functions for handling patchbay state.
* Do not free returned data.
*/
virtual const char* const* getPatchbayConnections() const;
virtual void restorePatchbayConnection(const char* const sourcePort, const char* const targetPort);


+ 0
- 3
source/backend/engine/CarlaEngine.cpp View File

@@ -1140,9 +1140,6 @@ bool CarlaEngine::saveProject(const char* const filename)
out << " <Source>" << connSource << "</Source>\n";
out << " <Target>" << connTarget << "</Target>\n";
out << " </Connection>\n";

delete[] connSource;
delete[] connTarget;
}

out << " </Patchbay>\n";


+ 9
- 14
source/backend/engine/CarlaEngineJack.cpp View File

@@ -23,6 +23,7 @@
#include "CarlaMathUtils.hpp"
#include "CarlaMIDI.h"
#include "CarlaPatchbayUtils.hpp"
#include "CarlaStringList.hpp"

#include "jackbridge/JackBridge.hpp"
#include "jackey.h"
@@ -1136,7 +1137,7 @@ public:
CARLA_SAFE_ASSERT_RETURN(fClient != nullptr, nullptr);
carla_debug("CarlaEngineJack::getPatchbayConnections()");

LinkedList<const char*> connList;
CarlaStringList connList;

if (const char** const ports = jackbridge_get_ports(fClient, nullptr, nullptr, JackPortIsOutput))
{
@@ -1151,8 +1152,8 @@ public:
{
for (int j=0; connections[j] != nullptr; ++j)
{
connList.append(carla_strdup(fullPortName));
connList.append(carla_strdup(connections[j]));
connList.append(fullPortName);
connList.append(connections[j]);
}

jackbridge_free(connections);
@@ -1162,20 +1163,12 @@ public:
jackbridge_free(ports);
}

const size_t connCount(connList.count());

if (connCount == 0)
if (connList.count() == 0)
return nullptr;

const char** const retConns = new const char*[connCount+1];

for (size_t i=0; i < connCount; ++i)
retConns[i] = connList.getAt(i, nullptr);
fRetConns = connList.toCharStringListPtr();

retConns[connCount] = nullptr;
connList.clear();

return retConns;
return fRetConns;
}

void restorePatchbayConnection(const char* const connSource, const char* const connTarget) override
@@ -1671,6 +1664,8 @@ private:
PatchbayConnectionList fUsedConnections;
LinkedList<uint> fNewGroups;

mutable CharStringListPtr fRetConns;

bool findPluginIdAndIcon(const char* const clientName, int& pluginId, PatchbayIcon& icon) noexcept
{
carla_debug("CarlaEngineJack::findPluginIdAndIcon(\"%s\", ...)", clientName);


Loading…
Cancel
Save