Versions Compared

Key

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

...

In this example derived from Dowd, an automatic variable is used as an argument to putenv(). The TEST environment variable may take on an unintended value if it is accessed once func() has returned and the stack frame where containing env is declared has been deallocatedrecycled.

Note that this example also violates rule DCL30-C. Do not refer to an object outside of its lifetime.

...