mirror of
https://github.com/php/php-src.git
synced 2026-04-05 07:02:33 +02:00
fix memleak in php 5.2, simplify code slightly
This commit is contained in:
@@ -2555,21 +2555,13 @@ static long stream_fteller_for_zend(void *handle TSRMLS_DC) /* {{{ */
|
||||
zend_op_array *(*phar_orig_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC);
|
||||
#if PHP_VERSION_ID >= 50300
|
||||
#define phar_orig_zend_open zend_stream_open_function
|
||||
#else
|
||||
int (*phar_orig_zend_open)(const char *filename, zend_file_handle *handle TSRMLS_DC);
|
||||
#endif
|
||||
|
||||
/*
|
||||
Used to add the fake CWD to include_path prior to parsing it in PHP 5.3+
|
||||
Does complete include_path scan for file in PHP 5.2
|
||||
|
||||
This is only called in PHP 5.2 if we know for certain that we are running within
|
||||
a phar, and only supports phar stream wrapper in 5.2.
|
||||
*/
|
||||
char *phar_resolve_path(const char *filename, int filename_len TSRMLS_DC)
|
||||
{
|
||||
return phar_find_in_include_path((char *) filename, filename_len, NULL TSRMLS_CC);
|
||||
}
|
||||
#else
|
||||
int (*phar_orig_zend_open)(const char *filename, zend_file_handle *handle TSRMLS_DC);
|
||||
#endif
|
||||
|
||||
static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
@@ -2669,6 +2661,9 @@ int phar_zend_open(const char *filename, zend_file_handle *handle TSRMLS_DC) /*
|
||||
if (!handle->opened_path) {
|
||||
handle->opened_path = entry;
|
||||
}
|
||||
if (entry != filename) {
|
||||
handle->free_filename = 1;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
if (entry != filename) {
|
||||
|
||||
@@ -361,10 +361,7 @@ doit:
|
||||
}
|
||||
}
|
||||
/* test for stream wrappers and return */
|
||||
for (p = filename; p - filename < filename_len && (isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'); p++) {
|
||||
n++;
|
||||
}
|
||||
|
||||
for (p = filename; p - filename < filename_len && (isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'); p++, n++);
|
||||
if (n < filename_len - 3 && (*p == ':') && (!strncmp("//", p+1, 2) || ( filename_len > 4 && !memcmp("data", filename, 4)))) {
|
||||
/* found stream wrapper, this is an absolute path until stream wrappers implement realpath */
|
||||
return estrndup(filename, filename_len);
|
||||
@@ -381,9 +378,7 @@ doit:
|
||||
maybe_stream = 0;
|
||||
goto not_stream;
|
||||
}
|
||||
for (p = ptr, n = 0; p < end && (isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'); p++) {
|
||||
n++;
|
||||
}
|
||||
for (p = ptr, n = 0; p < end && (isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'); p++, n++);
|
||||
|
||||
if (n == end - ptr && *p && !strncmp("//", p+1, 2)) {
|
||||
is_stream_wrapper = 1;
|
||||
@@ -480,9 +475,7 @@ not_stream:
|
||||
memcpy(trypath+exec_fname_length + 1, filename, filename_len+1);
|
||||
|
||||
/* search for stream wrapper */
|
||||
for (p = trypath; isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'; p++) {
|
||||
n++;
|
||||
}
|
||||
for (p = trypath; isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'; p++, n++);
|
||||
if (n < exec_fname_length - 3 && (*p == ':') && (n > 1) && (!strncmp("//", p+1, 2) || !memcmp("data", trypath, 4))) {
|
||||
char *actual;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user