Skip to content

Commit 9799cf9

Browse files
committed
Reset property table for disabled classes
To avoid retaining behavior about property visibility or types.
1 parent a3da562 commit 9799cf9

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Zend/tests/bug77494.phpt

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,21 @@ Bug #77494 (Disabling class causes segfault on member access)
33
--SKIPIF--
44
<?php if (!extension_loaded("curl")) exit("skip curl extension not loaded"); ?>
55
--INI--
6-
disable_classes=CURLFile
6+
disable_classes=CURLFile,ErrorException
77
--FILE--
88
<?php
99
$a = new CURLFile();
1010
var_dump($a->name);
11+
$b = new ErrorException();
12+
var_dump($b->message);
1113
?>
1214
--EXPECTF--
1315
Warning: CURLFile() has been disabled for security reasons in %sbug77494.php on line 2
1416

1517
Warning: Undefined property: CURLFile::$name in %s on line %d
1618
NULL
19+
20+
Warning: ErrorException() has been disabled for security reasons in %s on line %d
21+
22+
Warning: Undefined property: ErrorException::$message in %s on line %d
23+
NULL

Zend/zend_API.c

+4
Original file line numberDiff line numberDiff line change
@@ -3240,6 +3240,9 @@ ZEND_API zend_result zend_disable_class(const char *class_name, size_t class_nam
32403240
return FAILURE;
32413241
}
32423242

3243+
/* Will be reset by INIT_CLASS_ENTRY. */
3244+
free(disabled_class->interfaces);
3245+
32433246
INIT_CLASS_ENTRY_INIT_METHODS((*disabled_class), disabled_class_new);
32443247
disabled_class->create_object = display_disabled_class;
32453248

@@ -3250,6 +3253,7 @@ ZEND_API zend_result zend_disable_class(const char *class_name, size_t class_nam
32503253
}
32513254
} ZEND_HASH_FOREACH_END();
32523255
zend_hash_clean(&disabled_class->function_table);
3256+
zend_hash_clean(&disabled_class->properties_info);
32533257
return SUCCESS;
32543258
}
32553259
/* }}} */

0 commit comments

Comments
 (0)