浏览代码

1 more fix on encoding simple values in a variant

Stasik0 10 年之前
父节点
当前提交
109749d494
共有 1 个文件被更改,包括 2 次插入2 次删除
  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