Skip to content

Commit

Permalink
Fix crash in extractBrowseName (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
dpazj authored May 28, 2024
1 parent a6ef450 commit 2de34d9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Nodeset.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ NL_BrowseName extractBrowseName(const NamespaceList *namespaces, char *s)
{
NL_BrowseName bn;
bn.nsIdx = 0;
bn.name = NULL;
if (!s) return bn;
char *bnName = strchr(s, ':');
if (bnName == NULL)
{
Expand Down
3 changes: 3 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ target_include_directories(parser PRIVATE ${CHECK_INCLUDE_DIR})
add_test(NAME parser_Test
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND parser ${CMAKE_CURRENT_SOURCE_DIR}/basicNodeClasses.xml)
add_test(NAME parser_invalid_Test
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND parser ${CMAKE_CURRENT_SOURCE_DIR}/invalidNodeDefinitions.xml)

#these tests are simple loading nodesets and dumping it to stdout
add_test(NAME import_testNodeset WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND parserDemo ${PROJECT_SOURCE_DIR}/nodesets/testNodeset100nodes.xml)
Expand Down
10 changes: 10 additions & 0 deletions tests/invalidNodeDefinitions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<UANodeSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:uax="http://opcfoundation.org/UA/2008/02/Types.xsd" xmlns="http://opcfoundation.org/UA/2011/03/UANodeSet.xsd" xmlns:s1="http://yourorganisation.org/TestProjectsOpen/Types.xsd" xmlns:ua="http://unifiedautomation.com/Configuration/NodeSet.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<NamespaceUris>
<Uri>http://open62541.com/tests/BasicNodeClassTests/</Uri>
</NamespaceUris>
<UAObject>
</UAObject>
<UAObject BrowseName="1:">
</UAObject>
</UANodeSet>

0 comments on commit 2de34d9

Please sign in to comment.