Kaynağa Gözat

prevent a segfault in ClientNetworkLayerGetBuffer

Holger Jeromin 9 yıl önce
ebeveyn
işleme
3dee3beb88
1 değiştirilmiş dosya ile 2 ekleme ve 0 silme
  1. 2 0
      examples/networklayer_tcp.c

+ 2 - 0
examples/networklayer_tcp.c

@@ -450,6 +450,8 @@ UA_ServerNetworkLayer ServerNetworkLayerTCP_new(UA_ConnectionConfig conf, UA_UIn
 
 
 static UA_StatusCode ClientNetworkLayerGetBuffer(UA_Connection *connection, UA_ByteString *buf) {
 static UA_StatusCode ClientNetworkLayerGetBuffer(UA_Connection *connection, UA_ByteString *buf) {
 #ifndef UA_MULTITHREADING
 #ifndef UA_MULTITHREADING
+    if(connection->state == UA_CONNECTION_CLOSED)
+        return UA_STATUSCODE_BADCONNECTIONCLOSED;
     *buf = *(UA_ByteString*)connection->handle;
     *buf = *(UA_ByteString*)connection->handle;
     return UA_STATUSCODE_GOOD;
     return UA_STATUSCODE_GOOD;
 #else
 #else