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

Null pointer exception when reading a complex type with empty arrays.… #2799

Merged
merged 1 commit into from
Oct 14, 2024
Merged
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
52 changes: 26 additions & 26 deletions Stack/Opc.Ua.Core/Types/Encoders/BinaryDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1386,15 +1386,15 @@ public Array ReadArray(
switch (builtInType)
{
case BuiltInType.Boolean:
return ReadBooleanArray(fieldName).ToArray();
return ReadBooleanArray(fieldName)?.ToArray();
case BuiltInType.SByte:
return ReadSByteArray(fieldName).ToArray();
return ReadSByteArray(fieldName)?.ToArray();
case BuiltInType.Byte:
return ReadByteArray(fieldName).ToArray();
return ReadByteArray(fieldName)?.ToArray();
case BuiltInType.Int16:
return ReadInt16Array(fieldName).ToArray();
return ReadInt16Array(fieldName)?.ToArray();
case BuiltInType.UInt16:
return ReadUInt16Array(fieldName).ToArray();
return ReadUInt16Array(fieldName)?.ToArray();
case BuiltInType.Enumeration:
{
DetermineIEncodeableSystemType(ref systemType, encodeableTypeId);
Expand All @@ -1406,51 +1406,51 @@ public Array ReadArray(
goto case BuiltInType.Int32;
}
case BuiltInType.Int32:
return ReadInt32Array(fieldName).ToArray();
return ReadInt32Array(fieldName)?.ToArray();
case BuiltInType.UInt32:
return ReadUInt32Array(fieldName).ToArray();
return ReadUInt32Array(fieldName)?.ToArray();
case BuiltInType.Int64:
return ReadInt64Array(fieldName).ToArray();
return ReadInt64Array(fieldName)?.ToArray();
case BuiltInType.UInt64:
return ReadUInt64Array(fieldName).ToArray();
return ReadUInt64Array(fieldName)?.ToArray();
case BuiltInType.Float:
return ReadFloatArray(fieldName).ToArray();
return ReadFloatArray(fieldName)?.ToArray();
case BuiltInType.Double:
return ReadDoubleArray(fieldName).ToArray();
return ReadDoubleArray(fieldName)?.ToArray();
case BuiltInType.String:
return ReadStringArray(fieldName).ToArray();
return ReadStringArray(fieldName)?.ToArray();
case BuiltInType.DateTime:
return ReadDateTimeArray(fieldName).ToArray();
return ReadDateTimeArray(fieldName)?.ToArray();
case BuiltInType.Guid:
return ReadGuidArray(fieldName).ToArray();
return ReadGuidArray(fieldName)?.ToArray();
case BuiltInType.ByteString:
return ReadByteStringArray(fieldName).ToArray();
return ReadByteStringArray(fieldName)?.ToArray();
case BuiltInType.XmlElement:
return ReadXmlElementArray(fieldName).ToArray();
return ReadXmlElementArray(fieldName)?.ToArray();
case BuiltInType.NodeId:
return ReadNodeIdArray(fieldName).ToArray();
return ReadNodeIdArray(fieldName)?.ToArray();
case BuiltInType.ExpandedNodeId:
return ReadExpandedNodeIdArray(fieldName).ToArray();
return ReadExpandedNodeIdArray(fieldName)?.ToArray();
case BuiltInType.StatusCode:
return ReadStatusCodeArray(fieldName).ToArray();
return ReadStatusCodeArray(fieldName)?.ToArray();
case BuiltInType.QualifiedName:
return ReadQualifiedNameArray(fieldName).ToArray();
return ReadQualifiedNameArray(fieldName)?.ToArray();
case BuiltInType.LocalizedText:
return ReadLocalizedTextArray(fieldName).ToArray();
return ReadLocalizedTextArray(fieldName)?.ToArray();
case BuiltInType.DataValue:
return ReadDataValueArray(fieldName).ToArray();
return ReadDataValueArray(fieldName)?.ToArray();
case BuiltInType.Variant:
{
if (DetermineIEncodeableSystemType(ref systemType, encodeableTypeId))
{
return ReadEncodeableArray(fieldName, systemType, encodeableTypeId);
}
return ReadVariantArray(fieldName).ToArray();
return ReadVariantArray(fieldName)?.ToArray();
}
case BuiltInType.ExtensionObject:
return ReadExtensionObjectArray(fieldName).ToArray();
return ReadExtensionObjectArray(fieldName)?.ToArray();
case BuiltInType.DiagnosticInfo:
return ReadDiagnosticInfoArray(fieldName).ToArray();
return ReadDiagnosticInfoArray(fieldName)?.ToArray();
default:
{
if (DetermineIEncodeableSystemType(ref systemType, encodeableTypeId))
Expand Down Expand Up @@ -1604,7 +1604,7 @@ private bool DetermineIEncodeableSystemType(ref Type systemType, ExpandedNodeId
}

/// <summary>
/// Reads and returns an array of elements of the specified length and builtInType
/// Reads and returns an array of elements of the specified length and builtInType
/// </summary>
private Array ReadArrayElements(int length, BuiltInType builtInType)
{
Expand Down
Loading