ANSI C, hardware protection, out-of-bounds pointers
Doug Gwyn
gwyn at smoke.BRL.MIL
Sat Sep 9 11:29:49 AEST 1989
In article <9520 at chinet.chi.il.us> kdb at chinet.chi.il.us (Karl Botts) writes:
>Any standard implementation of malloc() et al. puts either the size
>of the block or a pointer to the next block in the machine word just
>before the start of the block ...
Not true. A "buddy system" allocator is MOST unlikely to do so.
>Thus you can be sure that mentioning this word (or even dereferencing it)
>will not cause an exception.
Even in such cases, it still wouldn't help with arrays of large objects,
because first-1 would point many bytes below the start of the allocated
data block.
Just don't use first-1. It's not that hard to avoid.
More information about the Comp.std.c
mailing list