Browse Source

1 more fix on encoding simple values in a variant

Stasik0 10 years ago
parent
commit
109749d494
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/ua_types_encoding_binary.c

+ 2 - 2
src/ua_types_encoding_binary.c

@@ -767,13 +767,13 @@ UA_StatusCode UA_Variant_decodeBinary(UA_ByteString const *src, size_t *offset,
     if(isArray || typeIndex != UA_TYPES_EXTENSIONOBJECT) {
         /* an array or a single builtin */
         const UA_DataType *dataType = &UA_TYPES[typeIndex];
-        UA_Int32 arraySize = 1;
+        UA_Int32 arraySize = -1;
         if(isArray) {
             retval |= UA_Int32_decodeBinary(src, offset, &arraySize);
             if(retval != UA_STATUSCODE_GOOD)
                 return retval;
         }
-        retval |= UA_Array_decodeBinary(src, offset, arraySize, &dst->dataPtr, dataType);
+        retval |= UA_Array_decodeBinary(src, offset, (arraySize==-1) ? 1: arraySize, &dst->dataPtr, dataType);
         if(retval != UA_STATUSCODE_GOOD)
             return retval;
         dst->arrayLength = arraySize; // for deleteMembers