projects
/
rtaudio.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8021795
)
Alsa API: Fix use of invalid card handle
185/head
author
Jakob Leben
<jakob.leben@gmail.com>
Tue, 12 Feb 2019 19:36:40 +0000
(11:36 -0800)
committer
Jakob Leben
<jakob.leben@gmail.com>
Tue, 12 Feb 2019 19:50:45 +0000
(11:50 -0800)
RtAudio.cpp
patch
|
blob
|
history
diff --git
a/RtAudio.cpp
b/RtAudio.cpp
index f72c899835b4283403d02bfaae12e31e057a2bc1..8c119a3462700235695b520f2a7a6ab5eb228c76 100644
(file)
--- a/
RtAudio.cpp
+++ b/
RtAudio.cpp
@@
-6937,7
+6937,7
@@
unsigned int RtApiAlsa :: getDeviceCount( void )
unsigned nDevices = 0;
int result, subdevice, card;
char name[64];
unsigned nDevices = 0;
int result, subdevice, card;
char name[64];
- snd_ctl_t *handle;
+ snd_ctl_t *handle
= 0
;
// Count cards and devices
card = -1;
// Count cards and devices
card = -1;
@@
-6946,6
+6946,7
@@
unsigned int RtApiAlsa :: getDeviceCount( void )
sprintf( name, "hw:%d", card );
result = snd_ctl_open( &handle, name, 0 );
if ( result < 0 ) {
sprintf( name, "hw:%d", card );
result = snd_ctl_open( &handle, name, 0 );
if ( result < 0 ) {
+ handle = 0;
errorStream_ << "RtApiAlsa::getDeviceCount: control open, card = " << card << ", " << snd_strerror( result ) << ".";
errorText_ = errorStream_.str();
error( RtAudioError::WARNING );
errorStream_ << "RtApiAlsa::getDeviceCount: control open, card = " << card << ", " << snd_strerror( result ) << ".";
errorText_ = errorStream_.str();
error( RtAudioError::WARNING );
@@
-6965,7
+6966,8
@@
unsigned int RtApiAlsa :: getDeviceCount( void )
nDevices++;
}
nextcard:
nDevices++;
}
nextcard:
- snd_ctl_close( handle );
+ if ( handle )
+ snd_ctl_close( handle );
snd_card_next( &card );
}
snd_card_next( &card );
}
@@
-6986,7
+6988,7
@@
RtAudio::DeviceInfo RtApiAlsa :: getDeviceInfo( unsigned int device )
unsigned nDevices = 0;
int result, subdevice, card;
char name[64];
unsigned nDevices = 0;
int result, subdevice, card;
char name[64];
- snd_ctl_t *chandle;
+ snd_ctl_t *chandle
= 0
;
// Count cards and devices
card = -1;
// Count cards and devices
card = -1;
@@
-6996,6
+6998,7
@@
RtAudio::DeviceInfo RtApiAlsa :: getDeviceInfo( unsigned int device )
sprintf( name, "hw:%d", card );
result = snd_ctl_open( &chandle, name, SND_CTL_NONBLOCK );
if ( result < 0 ) {
sprintf( name, "hw:%d", card );
result = snd_ctl_open( &chandle, name, SND_CTL_NONBLOCK );
if ( result < 0 ) {
+ chandle = 0;
errorStream_ << "RtApiAlsa::getDeviceInfo: control open, card = " << card << ", " << snd_strerror( result ) << ".";
errorText_ = errorStream_.str();
error( RtAudioError::WARNING );
errorStream_ << "RtApiAlsa::getDeviceInfo: control open, card = " << card << ", " << snd_strerror( result ) << ".";
errorText_ = errorStream_.str();
error( RtAudioError::WARNING );
@@
-7018,7
+7021,8
@@
RtAudio::DeviceInfo RtApiAlsa :: getDeviceInfo( unsigned int device )
nDevices++;
}
nextcard:
nDevices++;
}
nextcard:
- snd_ctl_close( chandle );
+ if ( chandle )
+ snd_ctl_close( chandle );
snd_card_next( &card );
}
snd_card_next( &card );
}