Re: 2.6.7-mm2, mmaps rework, buggy apps, setarch

From: Arjan van de Ven
Date: Fri Jun 25 2004 - 05:11:46 EST


On Fri, Jun 25, 2004 at 12:00:52PM +0200, Norbert Preining wrote:
> Hi Arjan!
>
> On Fre, 25 Jun 2004, Arjan van de Ven wrote:
> > > Can someone please explain me *what* the effects of a `buggy app' would
> > > be: Segfault I suppose. But what to do with a commerical app where I
> > > cannot check a stack trace or whatever?
> >
> > basically the applications that break do:
> >
> > int ptr;
> > ptr = malloc(some_size);
> > if (ptr <= 0)
> > handle_no_memory();
>
> Mmm, this looks very common. What is the `intended' way to handle this?

it's actually not common:
1) it stores a pointer in an int which isn't allowed
2) it uses < operator on a pointer

the correct way is

void * ptr;
ptr = malloc(some_size);
if (ptr == NULL)
handle_no_memory();

Attachment: pgp00000.pgp
Description: PGP signature