Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions ext/phar/phar_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -4518,28 +4518,27 @@ PHP_METHOD(PharFileInfo, __construct)
}
/* }}} */

#define PHAR_ENTRY_OBJECT() \
#define PHAR_ENTRY_OBJECT_EX(throw) \
zval *zobj = ZEND_THIS; \
phar_entry_object *entry_obj = (phar_entry_object*)((char*)Z_OBJ_P(zobj) - Z_OBJ_P(zobj)->handlers->offset); \
if (!entry_obj->entry) { \
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, \
"Cannot call method on an uninitialized PharFileInfo object"); \
RETURN_THROWS(); \
if (throw) { \
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, \
"Cannot call method on an uninitialized PharFileInfo object"); \
Comment on lines +4526 to +4527
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for a follow-up PR. This should probably converted to a standard Error exception as all other "attempting to do something on uninitialized object" exceptions

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do that we should do an entire pass over ext/phar so it is consistently fixed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, which is why this is future scope :)

} \
return; \
}

#define PHAR_ENTRY_OBJECT() PHAR_ENTRY_OBJECT_EX(true)

/* {{{ clean up directory-based entry objects */
PHP_METHOD(PharFileInfo, __destruct)
{
zval *zobj = ZEND_THIS;
phar_entry_object *entry_obj = (phar_entry_object*)((char*)Z_OBJ_P(zobj) - Z_OBJ_P(zobj)->handlers->offset);

if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}

if (!entry_obj->entry) {
return;
}
PHAR_ENTRY_OBJECT_EX(false);

if (entry_obj->entry->is_temp_dir) {
if (entry_obj->entry->filename) {
Expand Down