]> git.sesse.net Git - mlt/commitdiff
rtaudio/RtAudio.cpp: check for null pointer
authorMikko Rapeli <mikko.rapeli@iki.fi>
Tue, 31 Jul 2012 11:36:57 +0000 (13:36 +0200)
committerMikko Rapeli <mikko.rapeli@iki.fi>
Mon, 6 Aug 2012 16:37:27 +0000 (18:37 +0200)
Fixes Coverity CID 710858: Dereference after null check (FORWARD_NULL)
Comparing "this->rtapi_" to null implies that "this->rtapi_" might be null.
 146    if ( rtapi_ ) return;
...
Passing null variable "this->rtapi_" to function "RtApi::getDeviceCount()", which dereferences it. (The dereference happens because this is a virtual function call.)
 159    if ( rtapi_->getDeviceCount() ) break;

src/modules/rtaudio/RtAudio.cpp

index 249fa2567fb7a28ca9aae48871115d4485e14f27..422a78417b5a6eeaa008a37f9939f9fc4adc7ea8 100644 (file)
@@ -156,7 +156,7 @@ RtAudio :: RtAudio( RtAudio::Api api ) throw()
   getCompiledApi( apis );\r
   for ( unsigned int i=0; i<apis.size(); i++ ) {\r
     openRtApi( apis[i] );\r
-    if ( rtapi_->getDeviceCount() ) break;\r
+    if ( rtapi_ && rtapi_->getDeviceCount() ) break;\r
   }\r
 \r
   if ( rtapi_ ) return;\r