Versions Compared

Key

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

...

Non-Compliant Code Example

Wiki Markup
In this
example taken from Dowd et al., 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 containing env has been
 non-compliant coding example, an automatic variable is used as an argument to {{putenv()}} \[[Dowd 06|AA. C References#Dowd 06]\]. The {{TEST}} environment variable may take on an unintended value if it is accessed once {{func()}} has returned and the stack frame containing {{env}} has been recycled.

Wiki Markup
Note that this example also violates rule \[[DCL30-C. Declare objects with appropriate storage durations]\].

...

Wiki Markup
\[[Open Group 04|AA. C++ References#Open Group 04]\] The putenv() function
\[[ISO/IEC 9899-1999|AA. C References#ISO/IEC 9899-1999]\] Section 6.2.4, "Storage durations of objects," and Section 7.20.3, "Memory management functions"
\[[Dowd 06|AA. C References#Dowd 06]\] Chapter 10, "UNIX Processes" (Confusing putenv() and setenv())
\[[DCL30-C. Declare objects with appropriate storage durations]\]