Skip to content

Commit

Permalink
Merge pull request #221 from TomMuehlegger/master
Browse files Browse the repository at this point in the history
Comment out not required variable, which can cause an IndexOutOfBoundsException
  • Loading branch information
jogibear9988 authored Dec 1, 2024
2 parents ca881a2 + 72f493e commit 01e0395
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
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

0 comments on commit 01e0395

Please sign in to comment.