Michael McConville wrote:
> Mike Burns wrote:
> > On 2015-11-01 10.44.45 -0500, Michael McConville wrote:
> > > Index: history.c
> > > ===================================================================
> > > RCS file: /cvs/src/bin/ksh/history.c,v
> > > retrieving revision 1.52
> > > diff -u -p -r1.52 history.c
> > > --- history.c     1 Nov 2015 15:38:53 -0000       1.52
> > > +++ history.c     1 Nov 2015 15:44:02 -0000
> > > @@ -507,7 +507,7 @@ sethistsize(int n)
> > >                   cursize = n;
> > >           }
> > >  
> > > -         history = (char **)aresize(history, n*sizeof(char *), APERM);
> > > +         history = areallocarray(history, n, sizeof(char *), APERM);
> > 
> > Is this a memory leak? I'm thinking of the IDIOMS section of
> > realloc(3).
> 
> I don't think so. This is areallocarray(), a ksh-specific function, not
> the stdlib's reallocarray(3). I'm pretty sure that a failed allocation
> in ksh is fatal. It's defined in bin/ksh/alloc.c if you're interested.

Also, I think that idiom only applies when you're incrementing a size
variable (n, in this case) before reallocating.

Reply via email to