Skip to content

Commit

Permalink
prevent APIM size causing crash from badly converted double
Browse files Browse the repository at this point in the history
#45 was originally investigating this but after further testing there doesn't appear to be any issue
  • Loading branch information
Fma965 committed May 18, 2021
1 parent e8c7123 commit 742b714
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions Syn3Updater/Helper/USBHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,29 +257,32 @@ public async Task<string> LogParseXmlAction()
string apimsize = interrogatorLog?.POtaModuleSnapShot.PNode.D2P1AdditionalAttributes.D2P1PartitionHealth.Where(x => x.Type == "/fs/images/")
.Select(x => x.Total)
.Single();
double apimsizeint = Convert.ToDouble(apimsize?.Remove(apimsize.Length - 1));
_apimDetails.PartNumber = apimmodel;
if (apimsizeint >= 0 && apimsizeint <= 8)
double apimsizeint;
if (Double.TryParse(apimsize?.Remove(apimsize.Length - 1), out apimsizeint))
{
_apimDetails.Nav = false;
_apimDetails.Size = 8;
}
else if (apimsizeint >= 9 && apimsizeint <= 16)
{
_apimDetails.Nav = false;
_apimDetails.Size = 16;
}
else if (apimsizeint >= 17 && apimsizeint <= 32)
{
_apimDetails.Nav = true;
_apimDetails.Size = 32;
}
else if (apimsizeint >= 33 && apimsizeint <= 64)
{
_apimDetails.Nav = true;
_apimDetails.Size = 64;
if (apimsizeint >= 0 && apimsizeint <= 8)
{
_apimDetails.Nav = false;
_apimDetails.Size = 8;
}
else if (apimsizeint >= 9 && apimsizeint <= 16)
{
_apimDetails.Nav = false;
_apimDetails.Size = 16;
}
else if (apimsizeint >= 17 && apimsizeint <= 32)
{
_apimDetails.Nav = true;
_apimDetails.Size = 32;
}
else if (apimsizeint >= 33 && apimsizeint <= 64)
{
_apimDetails.Nav = true;
_apimDetails.Size = 64;
}
}

if (_apimDetails.Nav)
LogXmlDetails += $"{LM.GetValue("Utility.APIMType")} Navigation {Environment.NewLine}";
else
Expand Down

0 comments on commit 742b714

Please sign in to comment.