Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/core/midi/MidiApple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,9 @@ void MidiApple::midiInClose( MIDIEndpointRef reference )
char *getName( MIDIObjectRef &object )
{
// Returns the name of a given MIDIObjectRef as char *
CFStringRef name = nil;
CFStringRef name = nullptr;
if (noErr != MIDIObjectGetStringProperty(object, kMIDIPropertyName, &name))
return nil;
return nullptr;
int len = CFStringGetLength(name)+1;
char *value = (char *) malloc(len);

Expand Down Expand Up @@ -615,8 +615,12 @@ char * MidiApple::getFullName(MIDIEndpointRef &endpoint_ref)
char * deviceName = getName(device);
char * endPointName = getName(endpoint_ref);
qDebug("device name='%s' endpoint name='%s'",deviceName,endPointName);
char * fullName = (char *)malloc(strlen(deviceName) + strlen(":") + strlen(endPointName)+1);
size_t deviceNameLen = deviceName == nullptr ? 0 : strlen(deviceName);
size_t endPointNameLen = endPointName == nullptr ? 0 : strlen(endPointName);
char * fullName = (char *)malloc(deviceNameLen + endPointNameLen + 2);
sprintf(fullName, "%s:%s", deviceName,endPointName);
if (deviceName != nullptr) { free(deviceName); }
if (endPointName != nullptr) { free(endPointName); }
return fullName;
}

Expand Down