php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #55749
Patch getenv_notfound revision 2011-09-21 06:24 UTC by pajoye@php.net

Patch getenv_notfound for Unknown/Other Function Bug #55749

Patch version 2011-09-21 06:24 UTC

Return to Bug #55749 | Download this patch
Patch Revisions:

Developer: pajoye@php.net

Index: main/php_ini.c
===================================================================
--- main/php_ini.c	(revision 316909)
+++ main/php_ini.c	(working copy)
@@ -421,7 +421,11 @@
 					env_location = "";
 				} else {
 					size = GetEnvironmentVariableA("PHPRC", phprc_path, size);
-					env_location = phprc_path;
+					if (size == 0) {
+						env_location = "";
+					} else {
+						env_location = phprc_path;
+					}
 				}
 			}
 		}
Index: ext/standard/basic_functions.c
===================================================================
--- ext/standard/basic_functions.c	(revision 316909)
+++ ext/standard/basic_functions.c	(working copy)
@@ -3989,7 +3989,13 @@
 
 		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 */
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 10:01:30 2024 UTC