Browse Source

Fix crash with libjack port search requests

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.2.0-RC1
falkTX 4 years ago
parent
commit
85b1f4edc7
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
1 changed files with 10 additions and 4 deletions
  1. +10
    -4
      source/libjack/libjack_port-searching.cpp

+ 10
- 4
source/libjack/libjack_port-searching.cpp View File

@@ -1,6 +1,6 @@
/*
* Carla JACK API for external applications
* Copyright (C) 2016-2019 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2016-2020 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -56,7 +56,7 @@ const char** jack_get_ports(jack_client_t* client, const char* a, const char* b,

if (flags == 0 || (flags & (JackPortIsInput|JackPortIsOutput)) == (JackPortIsInput|JackPortIsOutput))
{
if (const char** const ret = (const char**)calloc(numIns+numOuts, sizeof(const char*)))
if (const char** const ret = (const char**)calloc(numIns+numOuts+1, sizeof(const char*)))
{
uint i=0;
for (uint j=0; j<jserver.numAudioIns; ++i, ++j)
@@ -68,13 +68,15 @@ const char** jack_get_ports(jack_client_t* client, const char* a, const char* b,
for (uint j=0; j<jserver.numMidiOuts; ++i, ++j)
ret[i] = allocate_port_name("system:midi_playback_", j);

ret[i] = nullptr;

return ret;
}
}

if (flags & JackPortIsInput)
{
if (const char** const ret = (const char**)calloc(numIns, sizeof(const char*)))
if (const char** const ret = (const char**)calloc(numIns+1, sizeof(const char*)))
{
uint i=0;
for (uint j=0; j<jserver.numAudioOuts; ++i, ++j)
@@ -82,13 +84,15 @@ const char** jack_get_ports(jack_client_t* client, const char* a, const char* b,
for (uint j=0; j<jserver.numMidiOuts; ++i, ++j)
ret[i] = allocate_port_name("system:midi_playback_", j);

ret[i] = nullptr;

return ret;
}
}

if (flags & JackPortIsOutput)
{
if (const char** const ret = (const char**)calloc(numOuts, sizeof(const char*)))
if (const char** const ret = (const char**)calloc(numOuts+1, sizeof(const char*)))
{
uint i=0;
for (uint j=0; j<jserver.numAudioIns; ++i, ++j)
@@ -96,6 +100,8 @@ const char** jack_get_ports(jack_client_t* client, const char* a, const char* b,
for (uint j=0; j<jserver.numMidiIns; ++i, ++j)
ret[i] = allocate_port_name("system:midi_capture_", j);

ret[i] = nullptr;

return ret;
}
}


Loading…
Cancel
Save