Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This noncompliant code example assigns the address of the printf() function to the log_fn function pointer, which can be allocated in the stack or data segment.:

Code Block
bgColor#FFCCCC
langc
int (*log_fn)(const char *, ...) = printf;
/* ... */
log_fn("foo");

...

Microsoft Windows provides the EncodePointer() and DecodePointer() functions that encrypt and decrypt pointers using a secret that is unique to the given process.:

Code Block
bgColor#ccccff
langc
int (*log_fn)(const char *, ...) = EncodePointer(printf);
/* ... */
DecodePointer(log_fn)("foo");

...