summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGZharun <grygoriiz@wavesglobal.com>2015-03-01 14:36:06 +0200
committerPaul Davis <paul@linuxaudiosystems.com>2015-03-31 17:29:41 -0400
commit3f5bf264c3841051a914adacc919617dbb651468 (patch)
tree00c9dbe8984873dd86b3746e5601b7d7270c9d8b
parent85b4577d7a3d35c3d0f6bba734fe83f5d889de87 (diff)
[Summary] Fixed crash on MAC when MIDI device name is 0 ref
-rw-r--r--libs/backends/wavesaudio/portmidi/src/pm_mac/pmmacosxcm.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/libs/backends/wavesaudio/portmidi/src/pm_mac/pmmacosxcm.c b/libs/backends/wavesaudio/portmidi/src/pm_mac/pmmacosxcm.c
index 78513573d4..b0a6825e67 100644
--- a/libs/backends/wavesaudio/portmidi/src/pm_mac/pmmacosxcm.c
+++ b/libs/backends/wavesaudio/portmidi/src/pm_mac/pmmacosxcm.c
@@ -866,10 +866,14 @@ char* cm_get_full_endpoint_name(MIDIEndpointRef endpoint)
}
#endif
/* copy the string into our buffer */
- newName = (char *) malloc(CFStringGetLength(fullName) + 1);
- CFStringGetCString(fullName, newName, CFStringGetLength(fullName) + 1,
- defaultEncoding);
-
+ if (fullName) {
+ newName = (char *) malloc(CFStringGetLength(fullName) + 1);
+ CFStringGetCString(fullName, newName, CFStringGetLength(fullName) + 1,
+ defaultEncoding);
+ } else {
+ newName = NULL;
+ }
+
/* clean up */
#ifdef OLDCODE
if (endpointName) CFRelease(endpointName);
@@ -972,8 +976,12 @@ PmError pm_macosxcm_init(void)
pm_default_input_device_id = pm_descriptor_index;
/* Register this device with PortMidi */
- pm_add_device("CoreMIDI", cm_get_full_endpoint_name(endpoint),
- TRUE, (void *) (long) endpoint, &pm_macosx_in_dictionary);
+ char* full_endpoint_name = cm_get_full_endpoint_name(endpoint);
+ if (full_endpoint_name != NULL) {
+ pm_add_device("CoreMIDI", full_endpoint_name,
+ TRUE, (void *) (long) endpoint, &pm_macosx_in_dictionary);
+
+ }
}
/* Iterate over the MIDI output devices */
@@ -988,9 +996,12 @@ PmError pm_macosxcm_init(void)
pm_default_output_device_id = pm_descriptor_index;
/* Register this device with PortMidi */
- pm_add_device("CoreMIDI", cm_get_full_endpoint_name(endpoint),
- FALSE, (void *) (long) endpoint,
- &pm_macosx_out_dictionary);
+ char* full_endpoint_name = cm_get_full_endpoint_name(endpoint);
+ if (full_endpoint_name != NULL) {
+ pm_add_device("CoreMIDI", full_endpoint_name,
+ FALSE, (void *) (long) endpoint,
+ &pm_macosx_out_dictionary);
+ }
}
return pmNoError;