Microsoft KB Archive/235601

= BUG: Putenv function may cause memory leak when the function is used to remove or to replace an environment variable in Visual C++ =

Article ID: 235601

Article Last Modified on 9/6/2005

-

APPLIES TO


 * Microsoft Visual C++ 4.0 Standard Edition
 * Microsoft Visual C++ 4.1 Subscription
 * Microsoft Visual C++ 4.2 Enterprise Edition
 * Microsoft Visual C++ 5.0 Enterprise Edition
 * Microsoft Visual C++ 6.0 Enterprise Edition
 * Microsoft Visual C++ 4.2 Professional Edition
 * Microsoft Visual C++ 5.0 Professional Edition
 * Microsoft Visual C++ 6.0 Professional Edition
 * Microsoft Visual C++ 6.0 Standard Edition

-



This article was previously published under Q235601



SYMPTOMS
A memory leak results from calls to putenv in the following circumstances:


 * An environment variable is removed.
 * An environment variable is replaced.
 * The input parameter does not contain an equal sign (=) character.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.

This problem was corrected in Microsoft Visual C++ .NET.



Steps to Reproduce Behavior
The following sample code demonstrates the types of calls that will cause a memory leak.


 * 1) include 

void main {   for  {

putenv( "MYVAR1=mystring" ); // Replaces string MYVAR1 // after first iteration.

putenv( "MYVAR2=mystring" ); // Creates and removes MYVAR2. putenv( "MYVAR2=" );        //

putenv( "MYVAR3" );         // Invalid string missing "=". } }

Additional query words: kbvc400

Keywords: kbtshoot kbbug kbfix kbcrt kbnoupdate KB235601

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.