Skip to content

Commit 03a1fca

Browse files
committed
Fixed bug #62744 (dangling pointers made by zend_disable_class)
the test will be added while commit the fix for #62737
1 parent 49b202f commit 03a1fca

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ PHP NEWS
33
?? ??? 2012, PHP 5.3.16
44

55
- Core:
6+
. Fixed bug #62744 (dangling pointers made by zend_disable_class). (Laruence)
67
. Fixed bug #62716 (munmap() is called with the incorrect length).
78
(slangley@google.com)
89
. Fixed bug #60194 (--with-zend-multibyte and --enable-debug reports LEAK

Zend/zend_API.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2342,16 +2342,16 @@ static const zend_function_entry disabled_class_new[] = {
23422342

23432343
ZEND_API int zend_disable_class(char *class_name, uint class_name_length TSRMLS_DC) /* {{{ */
23442344
{
2345-
zend_class_entry disabled_class;
2345+
zend_class_entry **disabled_class;
23462346

23472347
zend_str_tolower(class_name, class_name_length);
2348-
if (zend_hash_del(CG(class_table), class_name, class_name_length+1)==FAILURE) {
2348+
if (zend_hash_find(CG(class_table), class_name, class_name_length+1, (void **)&disabled_class)==FAILURE) {
23492349
return FAILURE;
23502350
}
2351-
INIT_OVERLOADED_CLASS_ENTRY_EX(disabled_class, class_name, class_name_length, disabled_class_new, NULL, NULL, NULL, NULL, NULL);
2352-
disabled_class.create_object = display_disabled_class;
2353-
disabled_class.name_length = class_name_length;
2354-
zend_register_internal_class(&disabled_class TSRMLS_CC);
2351+
INIT_CLASS_ENTRY_INIT_METHODS((**disabled_class), disabled_class_new, NULL, NULL, NULL, NULL, NULL);
2352+
(*disabled_class)->create_object = display_disabled_class;
2353+
(*disabled_class)->builtin_functions = disabled_class_new;
2354+
zend_hash_clean(&((*disabled_class)->function_table));
23552355
return SUCCESS;
23562356
}
23572357
/* }}} */
@@ -2425,7 +2425,6 @@ static int zend_is_callable_check_class(const char *name, int name_len, zend_fca
24252425
}
24262426
/* }}} */
24272427

2428-
24292428
static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fcall_info_cache *fcc, int strict_class, char **error TSRMLS_DC) /* {{{ */
24302429
{
24312430
zend_class_entry *ce_org = fcc->calling_scope;

Zend/zend_API.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ typedef struct _zend_fcall_info_cache {
170170
int _len = class_name_len; \
171171
class_container.name = zend_strndup(class_name, _len); \
172172
class_container.name_length = _len; \
173+
INIT_CLASS_ENTRY_INIT_METHODS(class_container, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \
174+
}
175+
176+
#define INIT_CLASS_ENTRY_INIT_METHODS(class_container, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \
177+
{ \
173178
class_container.builtin_functions = functions; \
174179
class_container.constructor = NULL; \
175180
class_container.destructor = NULL; \

0 commit comments

Comments
 (0)