This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
memsetting a locale object
- From: Bourne <bourne at toughguy dot net>
- To: libstdc++ at gcc dot gnu dot org
- Date: Wed, 13 Nov 2002 10:46:21 +0530
- Subject: 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.