Browse Source

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 năm trước cách đây
mục cha
commit
4abb548795
1 tập tin đã thay đổi với 2 bổ sung1 xóa
  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)
 void _modbus_init_common(modbus_t *ctx)
 {
 {
-    /* Slave is initialized to -1 */
+    /* Slave and socket are initialized to -1 */
     ctx->slave = -1;
     ctx->slave = -1;
+    ctx->s = -1;
 
 
     ctx->debug = FALSE;
     ctx->debug = FALSE;
     ctx->error_recovery = FALSE;
     ctx->error_recovery = FALSE;