Skip to content

Commit 01e0395

Browse files
authored
Merge pull request #221 from TomMuehlegger/master
Comment out not required variable, which can cause an IndexOutOfBoundsException
2 parents ca881a2 + 72f493e commit 01e0395

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

LibNoDaveConnectionLibrary/DataTypes/Projectfolders/Step7V5/BlocksOfflineFolder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ public Block GetBlock(ProjectBlockInfo blkInfo, S7ConvertingOptions myConvOpt)
641641
retVal.Parameter = Parameter.GetInterfaceOrDBFromStep7ProjectString(myTmpBlk.blkinterface, ref ParaList, blkInfo.BlockType, false, this, retVal, myConvOpt);
642642
}
643643

644-
if (myTmpBlk.blockdescription != null)
644+
if (myTmpBlk.blockdescription != null && myTmpBlk.blockdescription.Length > 3)
645645
{
646646
retVal.Title = Project.ProjectEncoding.GetString(myTmpBlk.blockdescription, 3, myTmpBlk.blockdescription[1] - 4);
647647
retVal.Description = Project.ProjectEncoding.GetString(myTmpBlk.blockdescription, myTmpBlk.blockdescription[1], myTmpBlk.blockdescription.Length - myTmpBlk.blockdescription[1] - 1).Replace("\n", Environment.NewLine);

LibNoDaveConnectionLibrary/PLCs/S7_xxx/MC7/Helper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ static public int GetIntFromHexString(string myString)
410410
static public uint GetUIntFromHexString(string myString)
411411
{
412412
uint val = 0;
413-
foreach (char tmp in myString.ToLower().Replace("dw#16#", "").Replace("w#16#", "").Replace("b#16#", "").Replace("\t", ""))
413+
foreach (char tmp in myString.ToLower().Replace("//", "").Replace("dw#16#", "").Replace("w#16#", "").Replace("b#16#", "").Replace("\t", "").Trim())
414414
{
415415
val *= 16;
416416
switch (tmp)

LibNoDaveConnectionLibrary/PLCs/S7_xxx/MC7/JumpMarks.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ public static List<FunctionBlockRow> AddJumpmarks(List<FunctionBlockRow> myBlk,
5252

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

5759
for (int n = NetworkCount * 2 + 4; n < JumpMarks.Length; n += 5)
5860
{

LibNoDaveConnectionLibrary/Projectfiles/Step7ProjectV5.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1579,7 +1579,11 @@ override protected void LoadProject()
15791579
foreach (var cp in CPFolders.Where(x => x.SubModul != null))
15801580
{
15811581
if (cp.NetworkInterfaces == null) cp.NetworkInterfaces = new List<NetworkInterface>();
1582-
cp.NetworkInterfaces.AddRange(cp.SubModul.NetworkInterfaces);
1582+
1583+
if (cp.SubModul.NetworkInterfaces != null)
1584+
{
1585+
cp.NetworkInterfaces.AddRange(cp.SubModul.NetworkInterfaces);
1586+
}
15831587
CPFolders.Remove(cp.SubModul);
15841588
cp.SubModul = null;
15851589
repeat = true;

0 commit comments

Comments
 (0)