Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix crash on mac when no audio device exists.

Test for NULL pointer before trying to read its content
  • Loading branch information...
commit dfd909f5397ca09cdeeec192c83c199034614daa 1 parent 7e6f5fa
@jyavenard jyavenard authored
Showing with 17 additions and 6 deletions.
  1. +17 −6 mythtv/libs/libmyth/audio/audiooutputca.cpp
View
23 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);
Please sign in to comment.
Something went wrong with that request. Please try again.