From bc4f25337e048db7d7ec86cfb116cc3768473ff5 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 19 Apr 2013 22:59:50 +0200 Subject: More pointer sanity checks --- src/drumgizmo.cc | 4 +--- src/drumkitloader.cc | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index ba167b4..c30147f 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -263,9 +263,7 @@ bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples) i = kit.instruments[d]; } - if(!i->isValid()) continue; - - if(i == NULL) { + if(i == NULL || !i->isValid()) { ERR(drumgizmo, "Missing Instrument %d.\n", evs[e].instrument); continue; } diff --git a/src/drumkitloader.cc b/src/drumkitloader.cc index 45dcec3..be74624 100644 --- a/src/drumkitloader.cc +++ b/src/drumkitloader.cc @@ -81,13 +81,13 @@ void DrumKitLoader::thread_main() unsigned int count = 0; - if(!kit->isValid()) goto finish; + if(kit && !kit->isValid()) goto finish; { // Count total number of files that need loading: Instruments::iterator i = kit->instruments.begin(); while(i != kit->instruments.end()) { Instrument *instr = *i; - if(!instr->isValid()) goto finish; + if(instr && !instr->isValid()) goto finish; count += instr->audiofiles.size(); i++; @@ -100,7 +100,7 @@ void DrumKitLoader::thread_main() while(i != kit->instruments.end()) { Instrument *instr = *i; - if(!instr->isValid()) goto finish; + if(instr && !instr->isValid()) goto finish; std::vector::iterator a = instr->audiofiles.begin(); while(a != instr->audiofiles.end()) { @@ -113,7 +113,7 @@ void DrumKitLoader::thread_main() #endif AudioFile *af = *a; - if(!af->isValid()) goto finish; + if(af && !af->isValid()) goto finish; af->load(); loaded++; -- cgit v1.2.3