1
0
mirror of https://github.com/php/php-src.git synced 2026-04-07 16:13:32 +02:00

Merge branch 'PHP-7.4' into PHP-8.0

* PHP-7.4:
  Fix memory leak in Phar::webPhar() on Windows
This commit is contained in:
Christoph M. Becker
2021-01-05 14:24:59 +01:00

View File

@@ -609,7 +609,7 @@ PHP_METHOD(Phar, webPhar)
if (NULL == (z_script_name = zend_hash_str_find(_server, "SCRIPT_NAME", sizeof("SCRIPT_NAME")-1)) ||
IS_STRING != Z_TYPE_P(z_script_name) ||
!strstr(Z_STRVAL_P(z_script_name), basename)) {
return;
goto finish;
}
if (NULL != (z_path_info = zend_hash_str_find(_server, "PATH_INFO", sizeof("PATH_INFO")-1)) &&
@@ -634,7 +634,7 @@ PHP_METHOD(Phar, webPhar)
testit = sapi_getenv("SCRIPT_NAME", sizeof("SCRIPT_NAME")-1);
if (!(pt = strstr(testit, basename))) {
efree(testit);
return;
goto finish;
}
path_info = sapi_getenv("PATH_INFO", sizeof("PATH_INFO")-1);
@@ -659,7 +659,7 @@ PHP_METHOD(Phar, webPhar)
if (!(pt = strstr(path_info, basename))) {
/* this can happen with rewrite rules - and we have no idea what to do then, so return */
return;
goto finish;
}
entry_len = strlen(path_info);
@@ -707,7 +707,6 @@ PHP_METHOD(Phar, webPhar)
efree(pt);
zend_bailout();
return;
default:
zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: rewrite callback must return a string or false");
@@ -718,6 +717,9 @@ cleanup_fail:
}
efree(entry);
efree(pt);
#ifdef PHP_WIN32
efree(fname);
#endif
RETURN_THROWS();
}
}
@@ -791,9 +793,6 @@ cleanup_fail:
if (FAILURE == phar_get_archive(&phar, fname, fname_len, NULL, 0, NULL) ||
(info = phar_get_entry_info(phar, entry, entry_len, NULL, 0)) == NULL) {
phar_do_404(phar, fname, fname_len, f404, f404_len, entry, entry_len);
#ifdef PHP_WIN32
efree(fname);
#endif
zend_bailout();
}
@@ -847,6 +846,11 @@ cleanup_fail:
code = phar_file_type(&PHAR_G(mime_types), entry, &mime_type);
}
phar_file_action(phar, info, mime_type, code, entry, entry_len, fname, pt, ru, ru_len);
finish: ;
#ifdef PHP_WIN32
efree(fname);
#endif
}
/* }}} */