| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             [2009-11-29 14:44 UTC] val@php.net
  | 
    |||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 02:00:01 2025 UTC | 
Description: ------------ When using include/include_once, a memory leak occur. Reproduce code: --------------- * Compile PHP with --enable-debug flag * Use a PHP file with includes. test.php: <?php include 'test.inc'; ?> test.inc: <?php ?> The following patch remove the leak: *** bcompiler.c Wed Oct 4 10:45:28 2006 --- bcompiler.c.modif Sun Jul 12 00:06:37 2009 *************** *** 306,317 **** char *path_to_open; unsigned char magic[2]; static int has_gz = -1, has_bz = -1; if (has_gz == -1) has_gz = has_gzip_stream_support(TSRMLS_C); if (has_bz == -1) has_bz = has_bzip2_stream_support(TSRMLS_C); /* try to read magic */ ! stream = php_stream_open_wrapper(file_name, "rb", ENFORCE_SAFE_MODE|USE_PATH|IGNORE_URL_WIN|STREAM_OPEN_FOR_INCLUDE, opened_path); if (!stream) { BCOMPILER_DEBUG(("error opening file '%s'..\n", file_name)); return stream; --- 306,320 ---- char *path_to_open; unsigned char magic[2]; static int has_gz = -1, has_bz = -1; + char *local_opened_path = NULL; if (has_gz == -1) has_gz = has_gzip_stream_support(TSRMLS_C); if (has_bz == -1) has_bz = has_bzip2_stream_support(TSRMLS_C); /* try to read magic */ ! stream = php_stream_open_wrapper(file_name, "rb", ENFORCE_SAFE_MODE|USE_PATH|IGNORE_URL_WIN|STREAM_OPEN_FOR_INCLUDE, &local_opened_path); ! if (local_opened_path) ! efree(local_opened_path); if (!stream) { BCOMPILER_DEBUG(("error opening file '%s'..\n", file_name)); return stream; Expected result: ---------------- No memory leak Actual result: -------------- when starting test.php: /usr/freebsd-current/php-5.2.9/main/fopen_wrappers.c(668) : Freeing 0x28C32B4C (11 bytes), script=/tmp/t.php