On Sep 6, 8:12*am, Ben Bacarisse <ben.use...@bsb.me.uk> wrote:
> Ian Collins <ian-n...@hotmail.com> writes:
> > On 09/ 5/12 06:59 PM, jacob navia wrote:
> >> Le 05/09/12 00:13, Ian Collins a écrit :
> >>> Your example proves the point: you test the malloc, but assume the VLA.
>
> >> int fn(void)
> >> {
> >> * * * *int i;
> >> }
>
> >> You do not test for "int i;"
>
> >> We should ban then all stack allocation?
>
> >> What are you saying actually? I do not understand what you want.
>
> > VLAs are a vulnerability waiting to happen. *Not as bad as gets, but
> > dodgy none the less.
>
> I don't understand this. *I need more information. *My guess is that you
> are referring to environments that don't check stack accesses, but
> that's not really the fault of the language feature.
>
> There's a point I've been meaning to make, and I might as well inject
> here since it is at least tangentially related to the above. *On systems
> that check stack access I don't see anything logically different between
> using a VLA and doing the very common
>
> * if ((p = malloc(size)) == NULL) {
> * * * *fprintf(stderr, "Eek! *Out or memory.\n");
> * * * *exit(EXIT_FAILURE):
> * }
>
> Sure, you might have less stack available, and the error message you get
> from a stack overflow might be more cryptic, but VLAs are criticised on
> other grounds entirely.
This is probably before my time, but why wasn't a NULL returning
'alloca' equivalent included in the standard?
|