From 80c6243429ea1996ec0d3be2f42d33d92e5f578f Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 23 Feb 2008 15:00:53 +0000 Subject: fix stupid uses of Session::get_silent_buffers() from crashing ardour git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3116 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/session.cc | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'libs/ardour') diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index a992e89458..c1afa92684 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -4088,9 +4088,37 @@ Session::write_one_audio_track (AudioTrack& track, nframes_t start, nframes_t le vector& Session::get_silent_buffers (uint32_t howmany) { + if (howmany > _silent_buffers.size()) { + + error << string_compose (_("Programming error: get_silent_buffers() called for %1 buffers but only %2 exist"), + howmany, _silent_buffers.size()) << endmsg; + + if (howmany > 1000) { + cerr << "ABSURD: more than 1000 silent buffers requested!\n"; + abort (); + } + + while (howmany > _silent_buffers.size()) { + Sample *p = 0; + +#ifdef NO_POSIX_MEMALIGN + p = (Sample *) malloc(current_block_size * sizeof(Sample)); +#else + if (posix_memalign((void **)&p,CPU_CACHE_ALIGN,current_block_size * 4) != 0) { + fatal << string_compose (_("Memory allocation error: posix_memalign (%1 * %2) failed (%3)"), + current_block_size, sizeof (Sample), strerror (errno)) + << endmsg; + /*NOTREACHED*/ + } +#endif + _silent_buffers.push_back (p); + } + } + for (uint32_t i = 0; i < howmany; ++i) { memset (_silent_buffers[i], 0, sizeof (Sample) * current_block_size); } + return _silent_buffers; } -- cgit v1.2.3