Pārlūkot izejas kodu

Initialize socket to -1 to avoid write on standard output

When unitialized the socket can be 0 and write calls success.
Stéphane Raimbault 14 gadi atpakaļ
vecāks
revīzija
4abb548795
1 mainītis faili ar 2 papildinājumiem un 1 dzēšanām
  1. 2 1
      src/modbus.c

+ 2 - 1
src/modbus.c

@@ -1225,8 +1225,9 @@ int modbus_report_slave_id(modbus_t *ctx, uint8_t *data_dest)
 
 void _modbus_init_common(modbus_t *ctx)
 {
-    /* Slave is initialized to -1 */
+    /* Slave and socket are initialized to -1 */
     ctx->slave = -1;
+    ctx->s = -1;
 
     ctx->debug = FALSE;
     ctx->error_recovery = FALSE;