Skip to content

Commit

Permalink
Fixed memory leak in baud autodetect
Browse files Browse the repository at this point in the history
  • Loading branch information
gskjold committed Mar 11, 2023
1 parent cd27472 commit 938f9f6
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/AmsToMqttBridge.ino
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,6 @@ void setupHanPort(uint8_t pin, uint32_t baud, uint8_t parityOrdinal, bool invert
swSerial->end();
delete swSerial;
}
swSerial = new SoftwareSerial(pin);

SoftwareSerialConfig serialConfig;
switch(parityOrdinal) {
Expand All @@ -735,7 +734,7 @@ void setupHanPort(uint8_t pin, uint32_t baud, uint8_t parityOrdinal, bool invert
break;
}

SoftwareSerial *swSerial = new SoftwareSerial(pin, -1, invert);
swSerial = new SoftwareSerial(pin, -1, invert);
swSerial->begin(baud, serialConfig);
hanSerial = swSerial;

Expand Down

0 comments on commit 938f9f6

Please sign in to comment.