BUG: Putenv() Function Causes Memory Leak

ID: Q235601


The information in this article applies to:


SYMPTOMS

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


STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.


MORE INFORMATION

Steps to Reproduce Behavior

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


#include <stdlib.h>

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          : kbCRT kbVC500bug kbVC600bug kbDSupport kbGrpVCCompiler 
Version           : winnt:4.0,4.1,4.2,5.0,6.0
Platform          : winnt 
Issue type        : kbbug 

Last Reviewed: July 12, 1999