File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -50,12 +50,15 @@ USBMIDI::USBMIDI() {
50
50
51
51
// private function for setting a not null/empty MIDI device name limited to 32 characters
52
52
void USBMIDI::setDeviceName (const char * name) {
53
+ printf (" setName called" );
53
54
const uint8_t maxNameLength = 32 ; // tinyUSB Descriptor limit
54
55
if (name != nullptr && strlen (name) > 0 ) {
55
56
if (strlen (name) > maxNameLength) {
56
57
log_w (" USBMIDI: Device name too long, truncating to %d characters." , maxNameLength);
57
58
}
58
- midiUserDeviceName = new char [maxNameLength + 1 ]; // +1 for null-terminator
59
+ if (!midiUserDeviceName) {
60
+ midiUserDeviceName = new char [maxNameLength + 1 ]; // +1 for null-terminator
61
+ }
59
62
if (midiUserDeviceName) {
60
63
strncpy (midiUserDeviceName, name, maxNameLength);
61
64
// Ensure null-termination when overflowing
You can’t perform that action at this time.
0 commit comments