This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

memsetting a locale object


Hi, A small proggie of mine dumped core. And i fixed it by doing a NULL
pointer check in ~locale() in the library. Below are the complete
details.
Please let me know if i make sense in writing such a proggie, but if  i
am totally wrong then i apologise for wasting your time.:-(.
Yes !, i am a novice c++ programmer.

----------Program Begin----------
#include <locale>
using namespace std;
int main()
{
	locale* foobar = new locale("foo");
	memset(foobar,0,sizeof(class locale));
	delete foobar;
}
---------Program Ends-----------
And the fix i did was to check if _M_Impl was NULL or not before calling 
_M_Impl->_M_remove_reference().

I thank again for your time.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]