Browse Source

Fix memory leak when the given parity is invalid

Stéphane Raimbault 14 years ago
parent
commit
3707d37f82
1 changed files with 1 additions and 0 deletions
  1. 1 0
      src/modbus-rtu.c

+ 1 - 0
src/modbus-rtu.c

@@ -869,6 +869,7 @@ modbus_t* modbus_new_rtu(const char *device,
     if (parity == 'N' || parity == 'E' || parity == 'O') {
         ctx_rtu->parity = parity;
     } else {
+        modbus_free(ctx);
         errno = EINVAL;
         return NULL;
     }