do not check for NULL before calling free

soapy_support
Jiří Pinkava 7 years ago committed by Dimitri Stolnikov
parent e321095445
commit ac15e7897b
  1. 12
      lib/hackrf/hackrf_sink_c.cc
  2. 3
      lib/hackrf/hackrf_source_c.cc
  3. 3
      lib/miri/miri_source_c.cc
  4. 3
      lib/osmosdr/osmosdr_src_c.cc
  5. 3
      lib/rtl/rtl_source_c.cc
  6. 7
      lib/sdrplay/sdrplay_source_c.cc

@ -84,10 +84,8 @@ static inline bool cb_init(circular_buffer_t *cb, size_t capacity, size_t sz)
static inline void cb_free(circular_buffer_t *cb)
{
if (cb->buffer) {
free(cb->buffer);
cb->buffer = NULL;
}
free(cb->buffer);
cb->buffer = NULL;
// clear out other fields too, just to be safe
cb->buffer_end = 0;
cb->capacity = 0;
@ -278,10 +276,8 @@ hackrf_sink_c::~hackrf_sink_c ()
}
}
if (_buf) {
free(_buf);
_buf = NULL;
}
free(_buf);
_buf = NULL;
cb_free( &_cbuf );
}

@ -260,8 +260,7 @@ hackrf_source_c::~hackrf_source_c ()
if (_buf) {
for(unsigned int i = 0; i < _buf_num; ++i) {
if (_buf[i])
free(_buf[i]);
free(_buf[i]);
}
free(_buf);

@ -158,8 +158,7 @@ miri_source_c::~miri_source_c ()
if (_buf) {
for(unsigned int i = 0; i < _buf_num; ++i) {
if (_buf[i])
free(_buf[i]);
free(_buf[i]);
}
free(_buf);

@ -157,8 +157,7 @@ osmosdr_src_c::~osmosdr_src_c ()
if (_buf) {
for(unsigned int i = 0; i < _buf_num; ++i) {
if (_buf[i])
free(_buf[i]);
free(_buf[i]);
}
free(_buf);

@ -257,8 +257,7 @@ rtl_source_c::~rtl_source_c ()
if (_buf) {
for(unsigned int i = 0; i < _buf_num; ++i) {
if (_buf[i])
free(_buf[i]);
free(_buf[i]);
}
free(_buf);

@ -142,11 +142,8 @@ sdrplay_source_c::sdrplay_source_c (const std::string &args)
*/
sdrplay_source_c::~sdrplay_source_c ()
{
if (_dev != NULL)
{
free(_dev);
_dev = NULL;
}
free(_dev);
_dev = NULL;
_buf_mutex.lock();
if (_running)
{

Loading…
Cancel
Save