Kaydet (Commit) 7bbaa391 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Catch invalid null pointer operations early

Change-Id: I324d5a6e84e0d2121d8e4612e074b44ed5127b11
üst f36e64d8
......@@ -19,8 +19,11 @@
#ifndef INCLUDED_COM_SUN_STAR_UNO_REFERENCE_H
#define INCLUDED_COM_SUN_STAR_UNO_REFERENCE_H
#include <rtl/alloc.h>
#include <sal/config.h>
#include <cassert>
#include <rtl/alloc.h>
namespace com
{
......@@ -395,8 +398,10 @@ public:
@return UNacquired interface pointer
*/
inline interface_type * SAL_CALL operator -> () const
{ return castFromXInterface(_pInterface); }
inline interface_type * SAL_CALL operator -> () const {
assert(_pInterface != 0);
return castFromXInterface(_pInterface);
}
/** Gets interface pointer. This call does not acquire the interface.
......
......@@ -20,8 +20,11 @@
#ifndef INCLUDED_RTL_REF_HXX
#define INCLUDED_RTL_REF_HXX
#include <sal/config.h>
#include <cassert>
#include <sal/types.h>
#include <osl/diagnose.h>
#include <osl/interlck.h>
namespace rtl
......@@ -160,7 +163,7 @@ public:
*/
inline reference_type * SAL_CALL operator->() const
{
OSL_PRECOND(m_pBody, "Reference::operator->() : null body");
assert(m_pBody != 0);
return m_pBody;
}
......@@ -169,7 +172,7 @@ public:
*/
inline reference_type & SAL_CALL operator*() const
{
OSL_PRECOND(m_pBody, "Reference::operator*() : null body");
assert(m_pBody != 0);
return *m_pBody;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment