Skip to content

Commit

Permalink
Silence some Use of memory after it is freed
Browse files Browse the repository at this point in the history
  • Loading branch information
poire-z committed Jul 3, 2020
1 parent 2cf99fa commit 4f69b01
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions crengine/include/lvref.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ template <class T> class LVFastRef
inline void Release()
{
if ( _ptr ) {
if ( _ptr->Release()==0 ) {
if ( _ptr->Release()==0 ) { // NOLINT(clang-analyzer-cplusplus.NewDelete)
delete _ptr;
}
_ptr=NULL;
Expand Down Expand Up @@ -111,7 +111,7 @@ template <class T> class LVFastRef
{
_ptr = ref._ptr;
if ( _ptr )
_ptr->AddRef();
_ptr->AddRef(); // NOLINT(clang-analyzer-cplusplus.NewDelete)
}

/// Destructor.
Expand All @@ -135,7 +135,7 @@ template <class T> class LVFastRef
Release();
}
if ( ref._ptr )
(_ptr = ref._ptr)->AddRef();
(_ptr = ref._ptr)->AddRef(); // NOLINT(clang-analyzer-cplusplus.NewDelete)
return *this;
}

Expand All @@ -160,7 +160,7 @@ template <class T> class LVFastRef
/** Imitates usual pointer behavior.
Usual way to access object fields.
*/
T * operator -> () const { return _ptr; }
T * operator -> () const { return _ptr; } // NOLINT(clang-analyzer-cplusplus.NewDelete)

/// Dereferences pointer to object.
/** Imitates usual pointer behavior. */
Expand All @@ -176,7 +176,7 @@ template <class T> class LVFastRef
/** Usual way to get pointer value.
\return stored pointer to object.
*/
T * get() const { return _ptr; }
T * get() const { return _ptr; } // NOLINT(clang-analyzer-cplusplus.NewDelete)

/// Checks whether pointer is NULL or not.
/** \return true if pointer is NULL.
Expand Down Expand Up @@ -208,7 +208,7 @@ template <class T> class LVProtectedFastRef
{
T * res = NULL;
if ( _ptr ) {
if ( _ptr->Release()==0 ) {
if ( _ptr->Release()==0 ) { // NOLINT(clang-analyzer-cplusplus.NewDelete)
res = _ptr;
}
_ptr=NULL;
Expand Down Expand Up @@ -240,7 +240,7 @@ template <class T> class LVProtectedFastRef
REF_GUARD
_ptr = ref._ptr;
if ( _ptr )
_ptr->AddRef();
_ptr->AddRef(); // NOLINT(clang-analyzer-cplusplus.NewDelete)
}

/// Destructor.
Expand Down Expand Up @@ -317,7 +317,7 @@ template <class T> class LVProtectedFastRef
/** Imitates usual pointer behavior.
Usual way to access object fields.
*/
T * operator -> () const { return _ptr; }
T * operator -> () const { return _ptr; } // NOLINT(clang-analyzer-cplusplus.NewDelete)

/// Dereferences pointer to object.
/** Imitates usual pointer behavior. */
Expand All @@ -333,7 +333,7 @@ template <class T> class LVProtectedFastRef
/** Usual way to get pointer value.
\return stored pointer to object.
*/
T * get() const { return _ptr; }
T * get() const { return _ptr; } // NOLINT(clang-analyzer-cplusplus.NewDelete)

/// Checks whether pointer is NULL or not.
/** \return true if pointer is NULL.
Expand Down Expand Up @@ -364,11 +364,11 @@ template <class T> class LVRef
private:
ref_count_rec_t * _ptr;
//========================================
ref_count_rec_t * AddRef() const { ++_ptr->_refcount; return _ptr; }
ref_count_rec_t * AddRef() const { ++_ptr->_refcount; return _ptr; } // NOLINT(clang-analyzer-cplusplus.NewDelete)
//========================================
void Release()
{
if (--_ptr->_refcount == 0)
if (--_ptr->_refcount == 0) // NOLINT(clang-analyzer-cplusplus.NewDelete)
{
if (_ptr != &ref_count_rec_t::null_ref)
{
Expand Down Expand Up @@ -458,7 +458,7 @@ template <class T> class LVRef
}
else
{
if (_ptr->_obj!=obj)
if (_ptr->_obj!=obj) // NOLINT(clang-analyzer-cplusplus.NewDelete)
{
Release();
_ptr = new ref_count_rec_t(obj);
Expand All @@ -471,7 +471,7 @@ template <class T> class LVRef
/** Imitates usual pointer behavior.
Usual way to access object fields.
*/
T * operator -> () const { return reinterpret_cast<T*>(_ptr->_obj); }
T * operator -> () const { return reinterpret_cast<T*>(_ptr->_obj); } // NOLINT(clang-analyzer-cplusplus.NewDelete)

/// Dereferences pointer to object.
/** Imitates usual pointer behavior. */
Expand All @@ -492,13 +492,13 @@ template <class T> class LVRef
/// Checks whether pointer is NULL or not.
/** \return true if pointer is NULL.
\sa isNull() */
bool operator ! () const { return !_ptr->_obj; }
bool operator ! () const { return !_ptr->_obj; } // NOLINT(clang-analyzer-cplusplus.NewDelete)

/// Checks whether pointer is NULL or not.
/** \return true if pointer is NULL.
\sa operator !()
*/
bool isNull() const { return _ptr->_obj == NULL; }
bool isNull() const { return _ptr->_obj == NULL; } // NOLINT(clang-analyzer-cplusplus.NewDelete)
};

template <typename T >
Expand Down

0 comments on commit 4f69b01

Please sign in to comment.