]> granicus.if.org Git - php/commitdiff
use estrdup() and plug the leak
authorAntony Dovgal <tony2001@php.net>
Mon, 14 May 2007 12:19:25 +0000 (12:19 +0000)
committerAntony Dovgal <tony2001@php.net>
Mon, 14 May 2007 12:19:25 +0000 (12:19 +0000)
main/php_ini.c

index 3b8e58d8c64f5081d3adbe674846bdf9fa9e3710..06be3eb90e4f78c9fb9fdcd92dc76fed79dfb6bb 100644 (file)
@@ -358,11 +358,10 @@ int php_init_config(TSRMLS_D)
                                if ((envpath = getenv("PATH")) != NULL) {
                                        char *search_dir, search_path[MAXPATHLEN];
                                        char *last;
-                                       int pathlen = strlen(envpath) + 1;
-                                       path = malloc(pathlen);
-                                       memcpy(path, envpath, pathlen);
 
+                                       path = estrdup(envpath);
                                        search_dir = php_strtok_r(path, ":", &last);
+
                                        while (search_dir) {
                                                snprintf(search_path, MAXPATHLEN, "%s/%s", search_dir, sapi_module.executable_location);
                                                if (VCWD_REALPATH(search_path, binary_location) && !VCWD_ACCESS(binary_location, X_OK)) {
@@ -371,6 +370,7 @@ int php_init_config(TSRMLS_D)
                                                }
                                                search_dir = php_strtok_r(NULL, ":", &last);
                                        }
+                                       efree(path);
                                }
                                if (!found) {
                                        efree(binary_location);