longjmp()/setjmp() difference between gcc 3.3 (Apple) and gcc 3.4.x
Mike Stump
mrs@apple.com
Thu Jan 27 23:24:00 GMT 2005
On Jan 27, 2005, at 1:41 PM, Remy X.O. Martin wrote:
> What I'd need would be a magic function like
> PointerToValidAddress(void *ptr) which returns False if ptr doesn't
> point to a memory location I can read/write.
This is trivial enough on a real OS, but, this is an OS question.
Meta point, this list is not for asking how do I write programs. That
is off-topic.
> In absence, what is the best way to avoid a crash when accessing
> memory through a received --invalid-- pointer?
If you design your system so that you can validate pointers:
map<void *, kind> m;
pointer_lives (void *p, KIND k) {
m[p] = k;
}
pointer_dies (void *p) {
m[p] = dead;
}
bool valid_pointer (void *p, KIND k) {
reeturn (m[p] == k);
}
you can trivially check them before use.
More information about the Gcc
mailing list