Browse Source

fix deletion of uninitialised Variants

Julius Pfrommer 11 years ago
parent
commit
e24fd0adb2
2 changed files with 4 additions and 3 deletions
  1. 3 1
      src/ua_basictypes.c
  2. 1 2
      tests/check_memory.c

+ 3 - 1
src/ua_basictypes.c

@@ -1359,7 +1359,9 @@ UA_Int32 UA_Variant_decodeBinary(UA_ByteString const * src, UA_Int32 *pos, UA_Va
 UA_TYPE_METHOD_DELETE_STRUCT(UA_Variant)
 UA_Int32 UA_Variant_deleteMembers(UA_Variant  * p) {
 	UA_Int32 retval = UA_SUCCESS;
-	retval |= UA_Array_delete(p->data,p->arrayLength,UA_toIndex(p->vt->ns0Id));
+	if(p->data != UA_NULL) {
+		retval |= UA_Array_delete(p->data,p->arrayLength,UA_toIndex(p->vt->ns0Id));
+	}
 	return retval;
 }
 UA_Int32 UA_Variant_init(UA_Variant * p){

+ 1 - 2
tests/check_memory.c

@@ -97,8 +97,7 @@ START_TEST (decodeShallFailWithTruncatedBufferButSurvive)
 	//then
 	ck_assert_msg(retval!=UA_SUCCESS,"testing %s with half buffer",UA_[_i].name);
 	// finally
-	// FIXME: this crashes with types 23,77,78,142
-	// UA_[_i].delete(obj2);
+	UA_[_i].delete(obj2);
 	UA_ByteString_deleteMembers(&msg1);
 }
 END_TEST