Commit 4abb548795fb94a8832f9a735823fb4d85b14ca3

Authored by Stéphane Raimbault
1 parent 525aadb2

Initialize socket to -1 to avoid write on standard output

When unitialized the socket can be 0 and write calls success.
Showing 1 changed file with 2 additions and 1 deletions
src/modbus.c
@@ -1225,8 +1225,9 @@ int modbus_report_slave_id(modbus_t *ctx, uint8_t *data_dest) @@ -1225,8 +1225,9 @@ int modbus_report_slave_id(modbus_t *ctx, uint8_t *data_dest)
1225 1225
1226 void _modbus_init_common(modbus_t *ctx) 1226 void _modbus_init_common(modbus_t *ctx)
1227 { 1227 {
1228 - /* Slave is initialized to -1 */ 1228 + /* Slave and socket are initialized to -1 */
1229 ctx->slave = -1; 1229 ctx->slave = -1;
  1230 + ctx->s = -1;
1230 1231
1231 ctx->debug = FALSE; 1232 ctx->debug = FALSE;
1232 ctx->error_recovery = FALSE; 1233 ctx->error_recovery = FALSE;