]> granicus.if.org Git - php/commitdiff
- be sure to check if the var ha not been removed between the two calls
authorPierre Joye <pajoye@php.net>
Mon, 26 Sep 2011 08:49:28 +0000 (08:49 +0000)
committerPierre Joye <pajoye@php.net>
Mon, 26 Sep 2011 08:49:28 +0000 (08:49 +0000)
ext/standard/basic_functions.c

index aecefa3d94746a15551bd5197842898e59ceefa0..58e36c3cffdf4cc55e1cf38f227307c8404ef116 100644 (file)
@@ -4022,7 +4022,13 @@ PHP_FUNCTION(getenv)
 
                ptr = emalloc(size);
                size = GetEnvironmentVariableA(str, ptr, size);
-               RETURN_STRING(ptr, 0);
+               if (size == 0) {
+                               /* has been removed between the two calls */
+                               efree(ptr);
+                               RETURN_EMPTY_STRING();
+               } else {
+                       RETURN_STRING(ptr, 0);
+               }
        }
 #else
        /* system method returns a const */