Don't try to dereference a NULL ptr (the function 'ARDOUR::IO::nth()' can return...
authorJohn Emmas <johne53@tiscali.co.uk>
Tue, 27 Jan 2015 11:59:23 +0000 (11:59 +0000)
committerJohn Emmas <johne53@tiscali.co.uk>
Tue, 27 Jan 2015 11:59:23 +0000 (11:59 +0000)
commit302dc2bea34ac9b16b8010ce16f2bc72a3792fb1
tree3b8b280f32f24d173272b8126f9ef9883556e1d3
parent0f46d7b1076550054491d8668a7fcc9d21271574
Don't try to dereference a NULL ptr (the function 'ARDOUR::IO::nth()' can return an invalid ptr, so let's make sure we test for it)

Note 1: Potentially we could have the same issue with 'AutomationLine::nth()' (although the current code seems okay)

Note 2: This (specific) problem seems mostly to affect Mixbus3 when it tries to load an old (version2) session from Ardour2. Mixbus can mark certain IO ports as being 'unused'. While loading sessions, function 'ARDOUR::IO::ensure_ports_locked()' deletes any unused ports. But later, the function 'ARDOUR::IO::make_connections_2X()' was crashing while trying to connect those (now NULL) ports. This commit fixes that crash but there's some evidence that it might only have moved the problem elsewhere. The version2 sessions now open successfully - but an MSVC (Debug) build now crashes whilst closing them (the Release build however, is okay). Someone who's more familiar with the code than me should review the Mixbus3/Ardour2 loading procedure to make sure it's safe.
libs/ardour/audio_diskstream.cc
libs/ardour/io.cc