]> granicus.if.org Git - php/commitdiff
- Use emalloc() for opened_path now. This was a potential leak before.
authorAndi Gutmans <andi@php.net>
Thu, 31 Aug 2000 22:24:20 +0000 (22:24 +0000)
committerAndi Gutmans <andi@php.net>
Thu, 31 Aug 2000 22:24:20 +0000 (22:24 +0000)
- This patch has potential to break stuff but I tested it as much as I
- could. Fixes should be easy.

NEWS
Zend/zend-scanner.l
Zend/zend.c
Zend/zend_execute.c
main/configuration-parser.y
main/fopen_wrappers.c

diff --git a/NEWS b/NEWS
index 8a75ae1bc3eb85b08096cb90bb046648f19c57b2..3ba1a1c1c81bc8daea1342b0a167c05c7fc42d74 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@ PHP 4.0                                                                    NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 
 ?? ??? 2000, Version 4.0.3-dev
+- Internal opened_path variable now uses the Zend memory manager so that full
+  paths of files won't leak on unclean shutdown (Andi)
 - Removed support of print $obj automatically calling the __string_value()
   method. Instead define yourself a method such as toString() and use
   print $obj->toString() (Andi, Zend Engine)
index b78ff8cd4683f609b5056962b441260533654bb0..99feccfceb8e61cb962c286ad34dc1fa03e31bb4 100644 (file)
@@ -207,7 +207,7 @@ ZEND_API void zend_file_handle_dtor(zend_file_handle *fh)
 #endif
        }
        if (fh->opened_path) {
-               free(fh->opened_path);
+               efree(fh->opened_path);
        }
        if (fh->free_filename && fh->filename) {
                efree(fh->filename);
index 304f4740dda287d8179e14c49a6cb936de0c850d..3ba958f11a4200548c15077c90d3d323983d9d96 100644 (file)
@@ -214,7 +214,7 @@ ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int
 static FILE *zend_fopen_wrapper(const char *filename, char **opened_path)
 {
        if (opened_path) {
-               *opened_path = strdup(filename);
+               *opened_path = estrdup(filename);
        }
        return fopen(filename, "rb");
 }
index f8d1c1732261b324362d6e4ca7ace873f0b7753c..6232490bf371ad28713a13c0cb6df3ba5124d956 100644 (file)
@@ -2000,7 +2000,7 @@ send_by_ref:
                                                                        }
                                                                }
                                                                if (opened_path) {
-                                                                       free(opened_path);
+                                                                       efree(opened_path);
                                                                }
                                                                break;
                                                        }
index 374d680bd7a0bc09346953b53d800160b8a0de41..dcef335ea0f4ca40dd805526280cc8e0cf92728f 100644 (file)
@@ -223,13 +223,14 @@ int php_init_config(void)
                if (opened_path) {
                        zval tmp;
                        
-                       tmp.value.str.val = opened_path;
+                       tmp.value.str.val = strdup(opened_path);
                        tmp.value.str.len = strlen(opened_path);
                        tmp.type = IS_STRING;
                        zend_hash_update(&configuration_hash,"cfg_file_path",sizeof("cfg_file_path"),(void *) &tmp,sizeof(zval),NULL);
 #if DEBUG_CFG_PARSER
                        php_printf("INI file opened at '%s'\n",opened_path);
 #endif
+                       efree(opened_path);
                }
                        
                init_cfg_scanner();
index 638c771c9bc698f0eafb4afd12375ed02e41eb07..fa7c053f4b14e328d0512f52f9a5d6538bec41fd 100644 (file)
@@ -1077,7 +1077,8 @@ PHPAPI char *expand_filepath(const char *filepath, char *real_path)
                memcpy(real_path,new_state.cwd,copy_len);
                real_path[copy_len]='\0';
        } else {
-               real_path = new_state.cwd;
+               real_path = estrndup(new_state.cwd, new_state.cwd_length);
+               free(new_state.cwd);
        }
 
        return real_path;