wjwwood / serial

Cross-platform, Serial Port library written in C++
http://wjwwood.github.com/serial/
MIT License
2.13k stars 1.04k forks source link

Fix memory leak when exception is thrown by impl class. #198

Closed bsbaliga closed 5 years ago

bsbaliga commented 5 years ago

This fixes a memory leak when exceptions are thrown by the Impl classes in the read function variants of Serial::read (std::vector<uint8_t> &buffer, size_t size) & Serial::read (std::string &buffer, size_t size)

An alternate strategy for the fix could have been to use smart pointers but chose the proposed fix so as to be inline with the coding conventions used in the library.

wjwwood commented 5 years ago

Thanks!