Reset property table for disabled classes

To avoid retaining behavior about property visibility or types.
This commit is contained in:
Nikita Popov 2021-04-20 10:35:10 +02:00
parent a3da56226a
commit 9799cf989c
2 changed files with 12 additions and 1 deletions

View file

@ -3,14 +3,21 @@ Bug #77494 (Disabling class causes segfault on member access)
--SKIPIF--
<?php if (!extension_loaded("curl")) exit("skip curl extension not loaded"); ?>
--INI--
disable_classes=CURLFile
disable_classes=CURLFile,ErrorException
--FILE--
<?php
$a = new CURLFile();
var_dump($a->name);
$b = new ErrorException();
var_dump($b->message);
?>
--EXPECTF--
Warning: CURLFile() has been disabled for security reasons in %sbug77494.php on line 2
Warning: Undefined property: CURLFile::$name in %s on line %d
NULL
Warning: ErrorException() has been disabled for security reasons in %s on line %d
Warning: Undefined property: ErrorException::$message in %s on line %d
NULL

View file

@ -3240,6 +3240,9 @@ ZEND_API zend_result zend_disable_class(const char *class_name, size_t class_nam
return FAILURE;
}
/* Will be reset by INIT_CLASS_ENTRY. */
free(disabled_class->interfaces);
INIT_CLASS_ENTRY_INIT_METHODS((*disabled_class), disabled_class_new);
disabled_class->create_object = display_disabled_class;
@ -3250,6 +3253,7 @@ ZEND_API zend_result zend_disable_class(const char *class_name, size_t class_nam
}
} ZEND_HASH_FOREACH_END();
zend_hash_clean(&disabled_class->function_table);
zend_hash_clean(&disabled_class->properties_info);
return SUCCESS;
}
/* }}} */