Re: Unsafe C++ memory allocation with new operator

From: Serassio Guido <guido.serassio@dont-contact.us>
Date: Sat, 08 Jan 2005 20:18:11 +0100

Hi Henrik,

At 19.52 08/01/2005, Henrik Nordstrom wrote:

>On Sat, 8 Jan 2005, Serassio Guido wrote:
>
>>On Linux this change works fine, but on Windows, and may be on other
>>platforms, Squid crashes when parsing squid.conf because the memory used
>>is not set to zero like on Linux.
>
>xmalloc does not clear memory on Linux either.

Yes, probably on my machine it happens casually.

> From my understanding of C++ the new operator is not supposed to
> guarantee the memory is cleared. This is the job of the constructor and
> related member initializers, where the default constructor memsets the
> object to 0.

So, in the Robert's patch something should be wrong: he changed a xcalloc()
call with a new operator.

Regards

Guido

-
========================================================
Guido Serassio
Acme Consulting S.r.l. - Microsoft Certified Partner
Via Gorizia, 69 10136 - Torino - ITALY
Tel. : +39.011.3249426 Fax. : +39.011.3293665
Email: guido.serassio@acmeconsulting.it
WWW: http://www.acmeconsulting.it/
Received on Sat Jan 08 2005 - 12:18:33 MST

This archive was generated by hypermail pre-2.1.9 : Tue Feb 01 2005 - 12:00:02 MST