]> 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 18282a8daad4c68ee48a10d74d60375692d6324f..568e719e03d288a7cd02b9b18090f52f53006ef4 100644 (file)
@@ -4024,7 +4024,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 */