[omniORB] exception when returning from main when using CORBA::Any
Andrén Clas
clas.andren@aerotechtelub.se
Tue, 22 Jan 2002 11:07:39 +0100
PROBLEM DESCRIPTION:
When the program reaches the return o statement in main(), Visual C++ fails with a
Debug Assertion Failed, CrtIsValidHeapPointer(pUserData) exception. Why ?
I Would really appreciate any suggestions.
/ Clas Andrén, Sweden
CODE::
#include <iostream>
#include <tao/corba.h>
CORBA::Any* ReadSubject()
{
CORBA::Any_var any = new CORBA::Any();
const char* text = "Any";
any <<= text;
return any._retn();
}
CORBA::ORB_var gOrb;
int main ( int argc, char* argv[] )
{
try
{
gOrb = CORBA::ORB_init(argc, argv, "TAO");
CORBA::Any_var store = ReadSubject();
const char* result;
*store >>= result;
// EVERYTHING IS FINE HERE!!!
cout << "Result: " << result << endl;
gOrb->destroy();
}
catch(CORBA::Exception&)
{
cerr << "Caught CORBA::Exception." << endl;
}
catch(...)
{
cerr << "Caught unknown exception." << endl;
}
// THIS FAILS!!!
return 0;
}
]