[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Secure Dereference of NULL-Pointer when using list.h
GCC translates the expression into the offset of the field port_list as
intended, but doing this involves dereferencing a NULL-pointer
(evaluates to 0). The expression can only be correct if one assumes that
the dereference will be optimized away - why is it safe to assume that?
this is similar to the offsetof(...) macro (stddef.h). but basically
it (the offsetof macro at-least) works like this [consider a shorter
sample "& ((S *0) ->foo) )"]:
1. (( S *)0) : takes the integer zero and casts it as a pointer to S.
2. ((S *)0)->foo: dereferences that pointer to point to structure member foo.
3. &(((S *)0)->foo): computes the address of foo
does that make any sense ?
kind regards
anupam
--
In the beginning was the lambda, and the lambda was with Emacs, and
Emacs was the lambda.
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/