memory: Small changes to fix some memory leaks.

Four small leaks in *scam, sx1276, and ozw.  Added calls to
cleanup resources before throws.

Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
Noel Eck 2016-09-21 12:25:02 -07:00
parent 87b10e33d0
commit a57f1c9691
4 changed files with 4 additions and 0 deletions

View File

@ -468,6 +468,7 @@ bool GROVESCAM::storeImage(const char *fname)
goto retry;
else
{
fclose(file);
throw std::runtime_error(std::string(__FUNCTION__) +
": cksum error, maximum retries exceeded");
return false;

View File

@ -54,6 +54,7 @@ OZW::OZW()
if (pthread_mutex_init(&m_nodeLock, &mutexAttrib))
{
pthread_mutexattr_destroy(&mutexAttrib);
throw std::runtime_error(std::string(__FUNCTION__) +
": pthread_mutex_init(nodeLock) failed");
}

View File

@ -468,6 +468,7 @@ bool SCAM::storeImage(const char *fname)
goto retry;
else
{
fclose(file);
throw std::runtime_error(std::string(__FUNCTION__) +
": cksum error, maximum retries exceeded");
return false;

View File

@ -151,6 +151,7 @@ SX1276::SX1276(uint8_t chipRev, int bus, int cs, int resetPin, int dio0,
if (pthread_mutex_init(&m_intrLock, &mutexAttrib))
{
pthread_mutexattr_destroy(&mutexAttrib);
throw std::runtime_error(std::string(__FUNCTION__) +
": pthread_mutex_init(intrLock) failed");
}