Forráskód Böngészése

fixing a memleak in case the connection was already closed, relates #340

Stasik0 9 éve
szülő
commit
ba7d4e2433
1 módosított fájl, 4 hozzáadás és 3 törlés
  1. 4 3
      examples/networklayer_tcp.c

+ 4 - 3
examples/networklayer_tcp.c

@@ -458,13 +458,14 @@ static void ClientNetworkLayerReleaseBuffer(UA_Connection *connection, UA_ByteSt
 }
 
 static void ClientNetworkLayerClose(UA_Connection *connection) {
+#ifndef UA_MULTITHREADING
+    UA_ByteString_delete(connection->handle);
+    connection->handle = NULL;
+#endif
     if(connection->state == UA_CONNECTION_CLOSED)
         return;
     connection->state = UA_CONNECTION_CLOSED;
     socket_close(connection);
-#ifndef UA_MULTITHREADING
-    UA_ByteString_delete(connection->handle);
-#endif
 }
 
 /* we have no networklayer. instead, attach the reusable buffer to the handle */