Prechádzať zdrojové kódy

fix "funny" allocation indicated by valgrind

Julius Pfrommer 10 rokov pred
rodič
commit
d08cdf36f2
2 zmenil súbory, kde vykonal 2 pridanie a 2 odobranie
  1. 1 1
      src/ua_types.c
  2. 1 1
      src/ua_types_encoding_binary.c

+ 1 - 1
src/ua_types.c

@@ -291,7 +291,7 @@ UA_Int32 UA_ByteString_newMembers(UA_ByteString *p, UA_Int32 length) {
 	if((retval |= UA_alloc((void **)&p->data, length)) == UA_SUCCESS)
 		p->length = length;
 	else {
-		p->length = length;
+		p->length = -1;
 		p->data   = UA_NULL;
 	}
 	return retval;

+ 1 - 1
src/ua_types_encoding_binary.c

@@ -7,7 +7,7 @@
 
 UA_Int32 UA_Array_calcSizeBinary(UA_Int32 nElements, UA_VTable_Entry *vt, const void *data) {
 	if(vt == UA_NULL || data == UA_NULL)
-		return UA_ERROR;
+		return 0; // do not return error as the result will be used to allocate memory
 
 	UA_Int32  length     = sizeof(UA_Int32);
 	UA_UInt32 memSize    = vt->memSize;