This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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]

Re: [PATCH] Use calloc (x, y) instead malloc (x * y).


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


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