Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comment out not required variable, which can cause an IndexOutOfBoundsException #221

Merged
merged 4 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ public Block GetBlock(ProjectBlockInfo blkInfo, S7ConvertingOptions myConvOpt)
retVal.Parameter = Parameter.GetInterfaceOrDBFromStep7ProjectString(myTmpBlk.blkinterface, ref ParaList, blkInfo.BlockType, false, this, retVal, myConvOpt);
}

if (myTmpBlk.blockdescription != null)
if (myTmpBlk.blockdescription != null && myTmpBlk.blockdescription.Length > 3)
{
retVal.Title = Project.ProjectEncoding.GetString(myTmpBlk.blockdescription, 3, myTmpBlk.blockdescription[1] - 4);
retVal.Description = Project.ProjectEncoding.GetString(myTmpBlk.blockdescription, myTmpBlk.blockdescription[1], myTmpBlk.blockdescription.Length - myTmpBlk.blockdescription[1] - 1).Replace("\n", Environment.NewLine);
Expand Down
2 changes: 1 addition & 1 deletion LibNoDaveConnectionLibrary/PLCs/S7_xxx/MC7/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ static public int GetIntFromHexString(string myString)
static public uint GetUIntFromHexString(string myString)
{
uint val = 0;
foreach (char tmp in myString.ToLower().Replace("dw#16#", "").Replace("w#16#", "").Replace("b#16#", "").Replace("\t", ""))
foreach (char tmp in myString.ToLower().Replace("//", "").Replace("dw#16#", "").Replace("w#16#", "").Replace("b#16#", "").Replace("\t", "").Trim())
{
val *= 16;
switch (tmp)
Expand Down
4 changes: 3 additions & 1 deletion LibNoDaveConnectionLibrary/PLCs/S7_xxx/MC7/JumpMarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ public static List<FunctionBlockRow> AddJumpmarks(List<FunctionBlockRow> myBlk,

if (JumpMarks != null && JumpMarks.Length >= 5)
{
int anzJ = BitConverter.ToInt16(JumpMarks, NetworkCount * 2); //Todo: find out why it does not always contain the right amount of JumpNames
// Comment this out, as the variable anzJ is not used at all and it sometimes throws and IndexOutOfBounds Exception
// Eg. there are 68 jump marks, but the Network count is 40 => access from index 80 --> IOB Exception
// int anzJ = BitConverter.ToInt16(JumpMarks, NetworkCount * 2); //Todo: find out why it does not always contain the right amount of JumpNames

for (int n = NetworkCount * 2 + 4; n < JumpMarks.Length; n += 5)
{
Expand Down
6 changes: 5 additions & 1 deletion LibNoDaveConnectionLibrary/Projectfiles/Step7ProjectV5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1579,7 +1579,11 @@ override protected void LoadProject()
foreach (var cp in CPFolders.Where(x => x.SubModul != null))
{
if (cp.NetworkInterfaces == null) cp.NetworkInterfaces = new List<NetworkInterface>();
cp.NetworkInterfaces.AddRange(cp.SubModul.NetworkInterfaces);

if (cp.SubModul.NetworkInterfaces != null)
{
cp.NetworkInterfaces.AddRange(cp.SubModul.NetworkInterfaces);
}
CPFolders.Remove(cp.SubModul);
cp.SubModul = null;
repeat = true;
Expand Down
Loading