Skip to content

Commit 44aea65

Browse files
authored
phar: Change hacky check into an exception (#20160)
phar_metadata_tracker_unserialize_or_copy() is only ever preceded by phar_metadata_tracker_has_data() which won't throw. This check is quite hacky and it should always be the responsibility of the caller to avoid calling this, even the comment acknowledges this is a hack.
1 parent 715099e commit 44aea65

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

ext/phar/phar.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -595,13 +595,9 @@ zend_result phar_metadata_tracker_unserialize_or_copy(phar_metadata_tracker *tra
595595
const bool has_unserialize_options = unserialize_options != NULL && zend_hash_num_elements(unserialize_options) > 0;
596596
/* It should be impossible to create a zval in a persistent phar/entry. */
597597
ZEND_ASSERT(!persistent || Z_ISUNDEF(tracker->val));
598+
ZEND_ASSERT(!EG(exception));
598599

599600
if (Z_ISUNDEF(tracker->val) || has_unserialize_options) {
600-
if (EG(exception)) {
601-
/* Because other parts of the phar code haven't been updated to check for exceptions after doing something that may throw,
602-
* check for exceptions before potentially serializing/unserializing instead. */
603-
return FAILURE;
604-
}
605601
/* Persistent phars should always be unserialized. */
606602
const char *start;
607603
/* Assert it should not be possible to create raw data in a persistent phar (i.e. from cache_list) */

0 commit comments

Comments
 (0)