Browse Source

fixed a cleanup crash for unitialized client, @hfaham, this fixes your issue!

Stasik0 9 years ago
parent
commit
5e665ec563
2 changed files with 3 additions and 2 deletions
  1. 1 1
      src/client/ua_client.c
  2. 2 1
      src/ua_securechannel.c

+ 1 - 1
src/client/ua_client.c

@@ -29,7 +29,7 @@ const UA_EXPORT UA_ClientConfig UA_ClientConfig_standard =
        .maxMessageSize = 65536, .maxChunkCount = 1}};
 
 UA_Client * UA_Client_new(UA_ClientConfig config, UA_Logger logger) {
-    UA_Client *client = UA_malloc(sizeof(UA_Client));
+    UA_Client *client = UA_calloc(1, sizeof(UA_Client));
     if(!client)
         return UA_NULL;
 

+ 2 - 1
src/ua_securechannel.c

@@ -25,7 +25,8 @@ void UA_SecureChannel_deleteMembersCleanup(UA_SecureChannel *channel) {
     UA_Connection *c = channel->connection;
     if(c) {
         UA_Connection_detachSecureChannel(c);
-        c->close(c);
+        if(c->close)
+            c->close(c);
     }
     /* just remove the pointers and free the linked list (not the sessions) */
     struct SessionEntry *se;