Skip to content

Commit bf44b6e

Browse files
committed
ext/phar/phar.c: use zend_hash_str_exists() instead of fetching ptr and checking for NULL
Especially as the ptr is never used afterwards
1 parent fb81bdd commit bf44b6e

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

ext/phar/phar.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,6 @@ static zend_result phar_open_parsed_phar(char *fname, size_t fname_len, char *al
510510
&& ((alias && fname_len == phar->fname_len
511511
&& !strncmp(fname, phar->fname, fname_len)) || !alias)
512512
) {
513-
phar_entry_info *stub;
514513
#ifdef PHP_WIN32
515514
if (fname != save_fname) {
516515
free_alloca(fname, fname_use_heap);
@@ -526,7 +525,7 @@ static zend_result phar_open_parsed_phar(char *fname, size_t fname_len, char *al
526525
if (!is_data) {
527526
/* prevent any ".phar" without a stub getting through */
528527
if (!phar->halt_offset && !phar->is_brandnew && (phar->is_tar || phar->is_zip)) {
529-
if (PHAR_G(readonly) && NULL == (stub = zend_hash_str_find_ptr(&(phar->manifest), ".phar/stub.php", sizeof(".phar/stub.php")-1))) {
528+
if (PHAR_G(readonly) && !zend_hash_str_exists(&(phar->manifest), ZEND_STRL(".phar/stub.php"))) {
530529
if (error) {
531530
spprintf(error, 0, "'%s' is not a phar archive. Use PharData::__construct() for a standard zip or tar archive", fname);
532531
}
@@ -1354,8 +1353,7 @@ zend_result phar_open_or_create_filename(char *fname, size_t fname_len, char *al
13541353
}
13551354

13561355
if (PHAR_G(readonly) && !(*test)->is_data && ((*test)->is_tar || (*test)->is_zip)) {
1357-
phar_entry_info *stub;
1358-
if (NULL == (stub = zend_hash_str_find_ptr(&((*test)->manifest), ".phar/stub.php", sizeof(".phar/stub.php")-1))) {
1356+
if (!zend_hash_str_exists(&((*test)->manifest), ZEND_STRL(".phar/stub.php"))) {
13591357
spprintf(error, 0, "'%s' is not a phar archive. Use PharData::__construct() for a standard zip or tar archive", fname);
13601358
return FAILURE;
13611359
}

0 commit comments

Comments
 (0)