This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Use calloc (x, y) instead malloc (x * y).
- From: Andreas Jaeger <aj at suse dot com>
- To: OndÅej BÃlka <neleai at seznam dot cz>, libc-alpha at sourceware dot org
- Date: Fri, 25 Oct 2013 10:53:47 +0200
- Subject: Re: [PATCH] Use calloc (x, y) instead malloc (x * y).
- Authentication-results: sourceware.org; auth=none
- References: <20131025084008 dot GA17443 at domone>
On 10/25/2013 10:40 AM, OndÅej BÃlka wrote:
> Hi,
>
> As there were several bugs with possible overflows in malloc calculation
> we should try to prevent these. A simple heuristic is to use following
> cocinelle patch:
>
> @@ expression e1, e2; @@
>
> - malloc(e1 * e2)
> + calloc(e1, e2)
>
> To handle easy case. OK to commit?
calloc returns 0-initialized memory, malloc does not - so, this could be
a pessimization.
What about adding a wrapper around malloc instead?
Andreas
--
Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 NÃrnberg, Germany
GF: Jeff Hawn,Jennifer Guild,Felix ImendÃrffer,HRB16746 (AG NÃrnberg)
GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126