Permalink
Browse files

Fix crash on mac when no audio device exists.

Test for NULL pointer before trying to read its content
  • Loading branch information...
jyavenard committed Feb 29, 2012
1 parent 7e6f5fa commit dfd909f5397ca09cdeeec192c83c199034614daa
Showing with 17 additions and 6 deletions.
  1. +17 −6 mythtv/libs/libmyth/audio/audiooutputca.cpp
@@ -200,17 +200,28 @@ AudioOutputSettings* AudioOutputCA::GetOutputSettings(bool digital)
// Seek hardware sample rate available
int rate;
int *rates = d->RatesList(d->mDeviceID);
- int *p_rates = rates;
- while (*p_rates > 0 && (rate = settings->GetNextRate()))
+ if (rates == NULL)
{
- if (*p_rates == rate)
+ // Error retrieving rates, assume 48kHz
+ settings->AddSupportedRate(48000);
+ }
+ else
+ {
+ while ((rate = settings->GetNextRate()))
{
- settings->AddSupportedRate(*p_rates);
- p_rates++;
+ int *p_rates = rates;
+ while (*p_rates > 0)
+ {
+ if (*p_rates == rate)
+ {
+ settings->AddSupportedRate(*p_rates);
+ }
+ p_rates++;
+ }
}
+ free(rates);
}
- free(rates);
// Supported format: 16 bits audio or float
settings->AddSupportedFormat(FORMAT_S16);

0 comments on commit dfd909f

Please sign in to comment.