Private
Public Access
2
0

initio: Add safety checks inside MraaIo destructor

Signed-off-by: Adelin Dobre <adelin.dobre@rinftech.com>
Signed-off-by: Thomas Ingleby <thomas.ingleby@intel.com>
This commit is contained in:
Adelin Dobre
2018-12-21 13:51:03 +02:00
committed by Thomas Ingleby
parent eae4a0cfbf
commit 678e540291

View File

@@ -47,7 +47,7 @@ namespace mraa
class MraaIo class MraaIo
{ {
private: private:
mraa_io_descriptor* descs; mraa_io_descriptor* descs = nullptr;
public: public:
MraaIo(const std::string& initStr) : descs() MraaIo(const std::string& initStr) : descs()
@@ -109,10 +109,10 @@ class MraaIo
~MraaIo() ~MraaIo()
{ {
if (descs != nullptr) {
if (descs->leftover_str) { if (descs->leftover_str) {
free(descs->leftover_str); free(descs->leftover_str);
} }
if (descs->n_aio) { if (descs->n_aio) {
free(descs->aios); free(descs->aios);
} }
@@ -143,6 +143,7 @@ class MraaIo
/* Finally free the mraa_io_descriptor structure. */ /* Finally free the mraa_io_descriptor structure. */
free(descs); free(descs);
} }
}
public: public:
std::vector<Aio> aios; std::vector<Aio> aios;