[A K KARTIK <akkartik@mailcity.com>] libc/1158: glibc: segmentation fault within malloc

Wolfram Gloger wmglo@dent.med.uni-muenchen.de
Sat Jun 12 05:03:00 GMT 1999


> Could anybody with c++ knowledge look into the appended bug report and
> tell us what's wrong?  I get the same error with glibc 2.1.1.

No C++ knowledge necessary :-)... Just wasted 10 minutes on this..

> 	actnode = (node*) malloc (total_size * sizeof (actnode)) ;

What's wrong with this line ?

Hint: sizeof (type*) != sizeof (type).

Can someone write a Perl script to detect suspicious lines like this?

Morale: always use operator new in C++, it was designed with good
reason.

Regards,
Wolfram.
-- 
`Surf the sea, not double-u three...'
wmglo@dent.med.uni-muenchen.de


More information about the Libc-alpha mailing list