Commit 3707d37f82efb971f1041bea37ccd46b4583ae8e

Authored by Stéphane Raimbault
1 parent b57c70f7

Fix memory leak when the given parity is invalid

Showing 1 changed file with 1 additions and 0 deletions
src/modbus-rtu.c
... ... @@ -869,6 +869,7 @@ modbus_t* modbus_new_rtu(const char *device,
869 869 if (parity == 'N' || parity == 'E' || parity == 'O') {
870 870 ctx_rtu->parity = parity;
871 871 } else {
  872 + modbus_free(ctx);
872 873 errno = EINVAL;
873 874 return NULL;
874 875 }
... ...