1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-01 16:19:43 +02:00

Bug 2458 - Possible crash when clearing text field in Gain dialog

This commit is contained in:
Leland Lucius 2020-05-28 20:09:14 -05:00
parent cd38e0e76d
commit 8ae8e0f0a5

View File

@ -322,9 +322,16 @@ bool SliderDialog::TransferDataToWindow()
bool SliderDialog::TransferDataFromWindow() bool SliderDialog::TransferDataFromWindow()
{ {
double value; // Bug #2458
//
// If the user clears the text control, the ToDouble below will NOT set "value"
// since it checks the length of the incoming string and bypasses setting it if
// it's empty. So initialize "value" for good measure and check the return value
// of ToDouble for success before using "value".
double value = 0.0;
mTextCtrl->GetValue().ToDouble(&value); if (mTextCtrl->GetValue().ToDouble(&value))
{
if (mStyle == DB_SLIDER) if (mStyle == DB_SLIDER)
value = DB_TO_LINEAR(value); value = DB_TO_LINEAR(value);
mSlider->Set(value); mSlider->Set(value);
@ -332,6 +339,8 @@ bool SliderDialog::TransferDataFromWindow()
mpOrigin->Set(value); mpOrigin->Set(value);
mpOrigin->SendUpdate(value); mpOrigin->SendUpdate(value);
} }
}
return true; return true;
} }