Skip to content

Commit dfd909f

Browse files
committed
Fix crash on mac when no audio device exists.
Test for NULL pointer before trying to read its content
1 parent 7e6f5fa commit dfd909f

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

mythtv/libs/libmyth/audio/audiooutputca.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,17 +200,28 @@ AudioOutputSettings* AudioOutputCA::GetOutputSettings(bool digital)
200200
// Seek hardware sample rate available
201201
int rate;
202202
int *rates = d->RatesList(d->mDeviceID);
203-
int *p_rates = rates;
204203

205-
while (*p_rates > 0 && (rate = settings->GetNextRate()))
204+
if (rates == NULL)
206205
{
207-
if (*p_rates == rate)
206+
// Error retrieving rates, assume 48kHz
207+
settings->AddSupportedRate(48000);
208+
}
209+
else
210+
{
211+
while ((rate = settings->GetNextRate()))
208212
{
209-
settings->AddSupportedRate(*p_rates);
210-
p_rates++;
213+
int *p_rates = rates;
214+
while (*p_rates > 0)
215+
{
216+
if (*p_rates == rate)
217+
{
218+
settings->AddSupportedRate(*p_rates);
219+
}
220+
p_rates++;
221+
}
211222
}
223+
free(rates);
212224
}
213-
free(rates);
214225

215226
// Supported format: 16 bits audio or float
216227
settings->AddSupportedFormat(FORMAT_S16);

0 commit comments

Comments
 (0)