Possible Bug

Bruce Visscher bvisscher@mindspring.com
Sat, 07 Mar 1998 15:17:51 -0500


Martin Gee wrote:

> node::Assoc_var an_assoc = 0;

In CORBA, you do not use the null pointer when dealing with Object
References.  When you declare a T_var, you should just use the default
constructor:

	node::Assoc_var an_assoc; // initialize to nil object reference

If at a later time, you decide you need to set the var to a value that
indicates "does not point to anything" you should set it to a properly
typed nil object reference.  In this case it would be:

	an_assoc = node::Assoc_var::_nil();

This will release the old object and you can later test to see if the
object is nil via:

	if(CORBA::is_nil(an_assoc)) //...

One caveat is that you have to make sure that the (ever present but
hidden) reference count is not already 0 before you can assign the T_var
to nil.

> an_assoc = h->getStruct(15);   <-   core dumps on this call

This is not surprising since the assignment will attempt to release the
old object which undoubtedly involves dereferencing the null pointer.

Bruce