Browse Source

Merge pull request #633 from open62541/fix_clang_analyzer

fix a clang analyzer issue
Julius Pfrommer 8 years ago
parent
commit
852ddd5c32
1 changed files with 6 additions and 3 deletions
  1. 6 3
      src/ua_types_encoding_binary.c

+ 6 - 3
src/ua_types_encoding_binary.c

@@ -917,15 +917,18 @@ Variant_decodeBinary(bufpos pos, bufend end, UA_Variant *dst, const UA_DataType
 
         /* search for the datatype. use extensionobject if nothing is found */
         dst->type = &UA_TYPES[UA_TYPES_EXTENSIONOBJECT];
-        if(typeId.namespaceIndex == 0 && eo_encoding == UA_EXTENSIONOBJECT_ENCODED_BYTESTRING) {
+        if(typeId.namespaceIndex == 0 && typeId.identifierType == UA_NODEIDTYPE_NUMERIC &&
+           eo_encoding == UA_EXTENSIONOBJECT_ENCODED_BYTESTRING) {
+            UA_assert(typeId.identifier.byteString.data == NULL); /* for clang analyzer <= 3.7 */
             typeId.identifier.numeric -= UA_ENCODINGOFFSET_BINARY;
             if(findDataType(&typeId, &dst->type) == UA_STATUSCODE_GOOD)
                 (*pos) += 4; /* jump over the length (todo: check if length matches) */
             else
                 *pos = old_pos; /* jump back and decode as extensionobject */
-        } else
+        } else {
             *pos = old_pos; /* jump back and decode as extensionobject */
-        UA_NodeId_deleteMembers(&typeId);
+            UA_NodeId_deleteMembers(&typeId);
+        }
 
         /* decode the type */
         dst->data = UA_calloc(1, dst->type->memSize);