diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index aea0203394..559a9c616d 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -926,7 +926,9 @@ AudioSource::compute_and_write_peaks (Sample* buf, samplecnt_t first_sample, sam memcpy (buf2.get(), peak_leftovers, peak_leftover_cnt * sizeof (Sample)); /* the new stuff */ - memcpy (buf2.get()+peak_leftover_cnt, buf, cnt * sizeof (Sample)); + if (buf && cnt > 0) { + memcpy (buf2.get()+peak_leftover_cnt, buf, cnt * sizeof (Sample)); + } /* no more leftovers */ peak_leftover_cnt = 0; diff --git a/libs/backends/alsa/alsa_midi.cc b/libs/backends/alsa/alsa_midi.cc index d9d473a84d..8bf7f4aece 100644 --- a/libs/backends/alsa/alsa_midi.cc +++ b/libs/backends/alsa/alsa_midi.cc @@ -186,7 +186,7 @@ AlsaMidiIn::recv_event (pframes_t &time, uint8_t *data, size_t &size) if (vector.len[0] > 0) { memcpy ((uint8_t*)&h, vector.buf[0], vector.len[0]); } - assert(vector.buf[1] || vector.len[0] == sizeof(MidiEventHeader)); + assert(vector.buf[1]); memcpy (((uint8_t*)&h) + vector.len[0], vector.buf[1], sizeof(MidiEventHeader) - vector.len[0]); } diff --git a/libs/evoral/src/SMF.cpp b/libs/evoral/src/SMF.cpp index b5d34aa538..60d69c8a4d 100644 --- a/libs/evoral/src/SMF.cpp +++ b/libs/evoral/src/SMF.cpp @@ -326,6 +326,7 @@ SMF::read_event(uint32_t* delta_t, uint32_t* size, uint8_t** buf, event_id_t* no if (*size < (unsigned)event_size) { *buf = (uint8_t*)realloc(*buf, event_size); } + assert (*buf); memcpy(*buf, event->midi_buffer, size_t(event_size)); *size = event_size; if (((*buf)[0] & 0xF0) == 0x90 && (*buf)[2] == 0) {