Out-of-bounds pointers

7103_300 at uwovax.uwo.ca 7103_300 at uwovax.uwo.ca
Thu Oct 12 08:55:27 AEST 1989


In article <238 at bbxsda.UUCP>, scott at bbxsda.UUCP (Scott Amspoker) writes:
> It is customary for subroutines (such as free()) to save registers
> on the stack and restore their values upon return.  NOTHING IS
> BEING PASSED BACK TO THE CALLER!  The subroutine is merely
> restoring a register to its original value.  The value of the
> pointer is being pushed as an argument to the subroutine.  That
> value ultimately is discarded.  However, the register containing
> the pointer may also be pushed to preserve its value.  Please check
> some assembly code output of practically any C compiler of a function 
> that uses register variables.

This is an implementation issue, not a language issue. Obviously if
the architecture is such that popping that value off the stack will
cause a fault, then either free() will have to keep the address
valid or the value should not be popped. The user shouldn't be punished
if the compiler attempts to load an invalid address; but if the user
explicitly codes an invalid address calculation, then all bets are off.
--
Eric R. Smith
ersmith at uwovax.uwo.ca
ersmith at uwovax.bitnet



More information about the Comp.std.c mailing list