summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Joye <pajoye@php.net>2010-08-30 17:05:56 +0000
committerPierre Joye <pajoye@php.net>2010-08-30 17:05:56 +0000
commitc55632007e746fbdf7ff948aac64bb92eec1031a (patch)
tree5c65696f6502a3735b37884a0d9fde0ebb7a2cc1
parentf671ad62753daa8dce3cf1f2ce8048aa4e88153c (diff)
downloadphp-git-c55632007e746fbdf7ff948aac64bb92eec1031a.tar.gz
- fix possible leak and error while fetching PHPRC
-rw-r--r--main/php_ini.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/main/php_ini.c b/main/php_ini.c
index 2c699b1a4d..bc0bbf04ef 100644
--- a/main/php_ini.c
+++ b/main/php_ini.c
@@ -398,13 +398,35 @@ int php_init_config(TSRMLS_D)
static const char paths_separator[] = { ZEND_PATHS_SEPARATOR, 0 };
#ifdef PHP_WIN32
char *reg_location;
+ char phprc_path[MAXPATHLEN];
#endif
env_location = getenv("PHPRC");
+
+#ifdef PHP_WIN32
if (!env_location) {
- env_location = "";
+ char dummybuf;
+ int size;
+
+ SetLastError(0);
+
+ /*If the given bugger is not large enough to hold the data, the return value is
+ the buffer size, in characters, required to hold the string and its terminating
+ null character. We use this return value to alloc the final buffer. */
+ size = GetEnvironmentVariableA("PHPRC", &dummybuf, 0);
+ if (GetLastError() == ERROR_ENVVAR_NOT_FOUND) {
+ /* The environment variable doesn't exist. */
+ env_location = "";
+ } else {
+ if (size == 0) {
+ env_location = "";
+ } else {
+ size = GetEnvironmentVariableA("PHPRC", phprc_path, size);
+ env_location = phprc_path;
+ }
+ }
}
-
+#endif
/*
* Prepare search path
*/