Browse Source

Stack: Check for memory allocation success

Stefan Profanter 5 years ago
parent
commit
b66d533e0e
1 changed files with 4 additions and 0 deletions
  1. 4 0
      src/server/ua_server.c

+ 4 - 0
src/server/ua_server.c

@@ -216,6 +216,10 @@ UA_Server_new() {
 
     /* Create Namespaces 0 and 1 */
     server->namespaces = (UA_String *)UA_Array_new(2, &UA_TYPES[UA_TYPES_STRING]);
+	if(!server->namespaces) {
+		UA_Server_delete(server);
+		return NULL;
+	}
     server->namespaces[0] = UA_STRING_ALLOC("http://opcfoundation.org/UA/");
     UA_String_copy(&server->config.applicationDescription.applicationUri, &server->namespaces[1]);
     server->namespacesSize = 2;