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:
committed by
Thomas Ingleby
parent
eae4a0cfbf
commit
678e540291
@@ -47,7 +47,7 @@ namespace mraa
|
||||
class MraaIo
|
||||
{
|
||||
private:
|
||||
mraa_io_descriptor* descs;
|
||||
mraa_io_descriptor* descs = nullptr;
|
||||
|
||||
public:
|
||||
MraaIo(const std::string& initStr) : descs()
|
||||
@@ -109,10 +109,10 @@ class MraaIo
|
||||
|
||||
~MraaIo()
|
||||
{
|
||||
if (descs != nullptr) {
|
||||
if (descs->leftover_str) {
|
||||
free(descs->leftover_str);
|
||||
}
|
||||
|
||||
if (descs->n_aio) {
|
||||
free(descs->aios);
|
||||
}
|
||||
@@ -143,6 +143,7 @@ class MraaIo
|
||||
/* Finally free the mraa_io_descriptor structure. */
|
||||
free(descs);
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
std::vector<Aio> aios;
|
||||
|
||||
Reference in New Issue
Block a user