Skip to content

Commit

Permalink
Fix bug which causes memory leak due to incorrect usage of _ALLOC macros
Browse files Browse the repository at this point in the history
  • Loading branch information
Pro committed Nov 23, 2017
1 parent 34ef196 commit f327087
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions tools/nodeset_compiler/backend_open62541_datatypes.py
Expand Up @@ -75,22 +75,22 @@ def generateNodeValueCode(node, instanceName, asIndirect=False, max_string_lengt
if type(node) in [Boolean, Byte, SByte, Int16, UInt16, Int32, UInt32, Int64, UInt64, Float, Double]:
return "(UA_" + node.__class__.__name__ + ") " + str(node.value)
elif type(node) == String:
return generateStringCode(node.value, asIndirect, max_string_length)
return generateStringCode(node.value, alloc=asIndirect, max_string_length=max_string_length)
elif type(node) == XmlElement:
return generateXmlElementCode(node.value, asIndirect, max_string_length)
return generateXmlElementCode(node.value, alloc=asIndirect, max_string_length=max_string_length)
elif type(node) == ByteString:
# replace whitespaces between tags and remove newlines
return generateByteStringCode(re.sub(r">\s*<", "><", re.sub(r"[\r\n]+", "", node.value)), asIndirect, max_string_length)
return generateByteStringCode(re.sub(r">\s*<", "><", re.sub(r"[\r\n]+", "", node.value)), alloc=asIndirect, max_string_length=max_string_length)
elif type(node) == LocalizedText:
return generateLocalizedTextCode(node, asIndirect, max_string_length)
return generateLocalizedTextCode(node, alloc=asIndirect, max_string_length=max_string_length)
elif type(node) == NodeId:
return generateNodeIdCode(node)
elif type(node) == ExpandedNodeId:
return generateExpandedNodeIdCode(node)
elif type(node) == DateTime:
return generateDateTimeCode(node.value)
elif type(node) == QualifiedName:
return generateQualifiedNameCode(node.value, asIndirect, max_string_length)
return generateQualifiedNameCode(node.value, alloc=asIndirect, max_string_length=max_string_length)
elif type(node) == StatusCode:
raise Exception("generateNodeValueCode for type " + node.__class__.name + " not implemented")
elif type(node) == DiagnosticInfo:
Expand Down
6 changes: 3 additions & 3 deletions tools/nodeset_compiler/backend_open62541_nodes.py
Expand Up @@ -480,8 +480,8 @@ def generateNodeCode(node, supressGenerationOfAttribute, generate_ns0, parentref
elif isinstance(node, ViewNode):
code.extend(generateViewNodeCode(node))

code.append("attr.displayName = " + generateLocalizedTextCode(node.displayName, max_string_length) + ";")
code.append("attr.description = " + generateLocalizedTextCode(node.description, max_string_length) + ";")
code.append("attr.displayName = " + generateLocalizedTextCode(node.displayName, alloc=False, max_string_length=max_string_length) + ";")
code.append("attr.description = " + generateLocalizedTextCode(node.description, alloc=False, max_string_length=max_string_length) + ";")
code.append("attr.writeMask = %d;" % node.writeMask)
code.append("attr.userWriteMask = %d;" % node.userWriteMask)

Expand All @@ -501,7 +501,7 @@ def generateNodeCode(node, supressGenerationOfAttribute, generate_ns0, parentref
code.append(generateNodeIdCode(node.id) + ",")
code.append(generateNodeIdCode(parentNode) + ",")
code.append(generateNodeIdCode(parentRef) + ",")
code.append(generateQualifiedNameCode(node.browseName) + ",")
code.append(generateQualifiedNameCode(node.browseName, max_string_length=max_string_length) + ",")
if isinstance(node, VariableTypeNode):
# we need the HasSubtype reference
code.append(generateSubtypeOfDefinitionCode(node) + ",")
Expand Down

0 comments on commit f327087

Please sign in to comment.