mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-19 17:11:12 +02:00
fix the loading of projects with more than 2^31 samples in a waveclip, and possibly some other similar constraints on waveclips. This fixes a long-standing problem with long recordings being saved but unable to re-open them. Tested by Gale and Steve.
This commit is contained in:
@@ -145,6 +145,47 @@ bool XMLValueChecker::IsGoodInt(const wxString strInt)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool XMLValueChecker::IsGoodInt64(const wxString strInt)
|
||||
{
|
||||
if (!IsGoodString(strInt))
|
||||
return false;
|
||||
|
||||
// Check that the value won't overflow.
|
||||
// Signed 64-bit: -18446744073709551616 to +18446744073709551615, i.e., -2^64 to 2^64-1
|
||||
// We're strict about disallowing spaces and commas, and requiring minus sign to be first char for negative.
|
||||
const size_t lenMAXABS = strlen("18446744073709551615");
|
||||
const size_t lenStrInt = strInt.Length();
|
||||
|
||||
if (lenStrInt > (lenMAXABS + 1))
|
||||
return false;
|
||||
else if ((lenStrInt == (lenMAXABS + 1)) && (strInt[0] == '-'))
|
||||
{
|
||||
const int digitsMAXABS[] = {1, 8, 4, 4, 6, 7, 4, 4, 0, 7, 3, 7, 0, 9, 5, 5, 1, 6, 1, 7};
|
||||
unsigned int i;
|
||||
for (i = 0; i < lenMAXABS; i++)
|
||||
if (strInt[i+1] < '0' || strInt[i+1] > '9')
|
||||
return false; // not a digit
|
||||
|
||||
for (i = 0; i < lenMAXABS; i++)
|
||||
if (strInt[i+1] - '0' < digitsMAXABS[i])
|
||||
return true; // number is small enough
|
||||
return false;
|
||||
}
|
||||
else if (lenStrInt == lenMAXABS)
|
||||
{
|
||||
const int digitsMAXABS[] = {1, 8, 4, 4, 6, 7, 4, 4, 0, 7, 3, 7, 0, 9, 5, 5, 1, 6, 1, 6};
|
||||
unsigned int i;
|
||||
for (i = 0; i < lenMAXABS; i++)
|
||||
if (strInt[i] < '0' || strInt[i+1] > '9')
|
||||
return false; // not a digit
|
||||
for (i = 0; i < lenMAXABS; i++)
|
||||
if (strInt[i] - '0' < digitsMAXABS[i])
|
||||
return true; // number is small enough
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool XMLValueChecker::IsValidChannel(const int nValue)
|
||||
{
|
||||
return (nValue >= Track::LeftChannel) && (nValue <= Track::MonoChannel);
|
||||
|
@@ -37,10 +37,27 @@ public:
|
||||
static bool IsGoodPathName(const wxString strPathName);
|
||||
static bool IsGoodPathString(wxString str);
|
||||
|
||||
// Note that because wxString::ToLong does additional testing, IsGoodInt doesn't duplicate
|
||||
// that testing, so use wxString::ToLong after IsGoodInt, not just atoi.
|
||||
/** @brief Check that the supplied string can be converted to a long (32bit)
|
||||
* integer.
|
||||
*
|
||||
* Note that because wxString::ToLong does additional testing, IsGoodInt doesn't
|
||||
* duplicate that testing, so use wxString::ToLong after IsGoodInt, not just
|
||||
* atoi.
|
||||
* @param strInt The string to test
|
||||
* @return true if the string is convertable, false if not
|
||||
*/
|
||||
static bool IsGoodInt(const wxString strInt);
|
||||
|
||||
/** @brief Check that the supplied string can be converted to a 64bit
|
||||
* integer.
|
||||
*
|
||||
* Note that because wxString::ToLongLong does additional testing, IsGoodInt64
|
||||
* doesn't duplicate that testing, so use wxString::ToLongLong after IsGoodInt64
|
||||
* not just atoll.
|
||||
* @param strInt The string to test
|
||||
* @return true if the string is convertable, false if not
|
||||
*/
|
||||
static bool IsGoodInt64(const wxString strInt);
|
||||
|
||||
static bool IsValidChannel(const int nValue);
|
||||
#ifdef USE_MIDI
|
||||
static bool IsValidVisibleChannels(const int nValue);
|
||||
|
Reference in New Issue
Block a user