Skip to content

Commit

Permalink
- .NET API: fixed - crash when GetDataSetDirectoryAsync returns error
Browse files Browse the repository at this point in the history
  (LIB61850-434)
  • Loading branch information
mzillgith committed Mar 19, 2024
1 parent 249df01 commit 681d1b0
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions dotnet/IEC61850forCSharp/IEC61850ClientAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,9 @@ public List<string> GetDataDirectoryFC(string dataReference)

private static List<MmsJournalEntry> WrapNativeLogQueryResult(IntPtr linkedList)
{
if (linkedList == IntPtr.Zero)
return null;

List<MmsJournalEntry> journalEntries = new List<MmsJournalEntry>();

IntPtr element = LinkedList_getNext(linkedList);
Expand Down Expand Up @@ -2238,22 +2241,27 @@ private void nativeGetDataSetDirectoryHandler(UInt32 invokeId, IntPtr parameter,
GetDataSetDirectoryHandler handler = callbackInfo.Item1;
object handlerParameter = callbackInfo.Item2;

IntPtr element = LinkedList_getNext(dataSetDirectory);

handle.Free();

List<string> newList = new List<string>();
List<string> newList = null;

while (element != IntPtr.Zero)
if (dataSetDirectory != IntPtr.Zero)
{
string dataObject = Marshal.PtrToStringAnsi(LinkedList_getData(element));
newList = new List<string>();

newList.Add(dataObject);
IntPtr element = LinkedList_getNext(dataSetDirectory);

element = LinkedList_getNext(element);
}
while (element != IntPtr.Zero)
{
string dataObject = Marshal.PtrToStringAnsi(LinkedList_getData(element));

LinkedList_destroy(dataSetDirectory);
newList.Add(dataObject);

element = LinkedList_getNext(element);
}

LinkedList_destroy(dataSetDirectory);
}

handler.Invoke(invokeId, handlerParameter, (IedClientError)err, newList, isDeletable);
}
Expand Down Expand Up @@ -2428,11 +2436,9 @@ private void nativeReadDataSetHandler(UInt32 invokeId, IntPtr parameter, int err
dataSet = new DataSet(nativeDataSet);
}


handler(invokeId, handlerParameter, clientError, dataSet);
}


public delegate void ReadDataSetHandler(UInt32 invokeId,object parameter,IedClientError err,DataSet dataSet);

/// <summary>
Expand Down Expand Up @@ -2566,7 +2572,6 @@ private void nativeGetNameListHandler(UInt32 invokeId, IntPtr parameter, int err
{
handler(invokeId, handlerParameter, clientError, null, moreFollows);
}

}

/// <summary>
Expand Down Expand Up @@ -2632,7 +2637,6 @@ public UInt32 GetLogicalDeviceDataSetsAsync(string ldName, string continueAfter,
return GetLogicalDeviceDataSetsAsync(null, ldName, continueAfter, handler, parameter);
}


public UInt32 GetLogicalDeviceDataSetsAsync(List<string> result, string ldName, string continueAfter, GetNameListHandler handler, object parameter)
{
int error;
Expand Down

0 comments on commit 681d1b0

Please sign in to comment.