- .NET API: fixed - crash when GetDataSetDirectoryAsync returns error

(LIB61850-434)
pull/462/merge
Michael Zillgith 1 year ago
parent 249df0176a
commit 681d1b0e05

@ -1175,6 +1175,9 @@ namespace IEC61850
private static List<MmsJournalEntry> WrapNativeLogQueryResult(IntPtr linkedList) private static List<MmsJournalEntry> WrapNativeLogQueryResult(IntPtr linkedList)
{ {
if (linkedList == IntPtr.Zero)
return null;
List<MmsJournalEntry> journalEntries = new List<MmsJournalEntry>(); List<MmsJournalEntry> journalEntries = new List<MmsJournalEntry>();
IntPtr element = LinkedList_getNext(linkedList); IntPtr element = LinkedList_getNext(linkedList);
@ -2238,22 +2241,27 @@ namespace IEC61850
GetDataSetDirectoryHandler handler = callbackInfo.Item1; GetDataSetDirectoryHandler handler = callbackInfo.Item1;
object handlerParameter = callbackInfo.Item2; object handlerParameter = callbackInfo.Item2;
IntPtr element = LinkedList_getNext(dataSetDirectory);
handle.Free(); 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); handler.Invoke(invokeId, handlerParameter, (IedClientError)err, newList, isDeletable);
} }
@ -2428,11 +2436,9 @@ namespace IEC61850
dataSet = new DataSet(nativeDataSet); dataSet = new DataSet(nativeDataSet);
} }
handler(invokeId, handlerParameter, clientError, dataSet); handler(invokeId, handlerParameter, clientError, dataSet);
} }
public delegate void ReadDataSetHandler(UInt32 invokeId,object parameter,IedClientError err,DataSet dataSet); public delegate void ReadDataSetHandler(UInt32 invokeId,object parameter,IedClientError err,DataSet dataSet);
/// <summary> /// <summary>
@ -2566,7 +2572,6 @@ namespace IEC61850
{ {
handler(invokeId, handlerParameter, clientError, null, moreFollows); handler(invokeId, handlerParameter, clientError, null, moreFollows);
} }
} }
/// <summary> /// <summary>
@ -2632,7 +2637,6 @@ namespace IEC61850
return GetLogicalDeviceDataSetsAsync(null, ldName, continueAfter, handler, parameter); return GetLogicalDeviceDataSetsAsync(null, ldName, continueAfter, handler, parameter);
} }
public UInt32 GetLogicalDeviceDataSetsAsync(List<string> result, string ldName, string continueAfter, GetNameListHandler handler, object parameter) public UInt32 GetLogicalDeviceDataSetsAsync(List<string> result, string ldName, string continueAfter, GetNameListHandler handler, object parameter)
{ {
int error; int error;

Loading…
Cancel
Save