@@ -184,34 +184,27 @@ static zend_always_inline zend_bool zend_iterable_compatibility_check(zend_arg_i
184
184
}
185
185
/* }}} */
186
186
187
- /* todo: this is probably useful elsewhere too */
188
- /* caller is responsible for adding any necessary refcount */
189
187
static zend_string * _get_parent_class_name (zend_class_entry * ce )
190
- { /* {{{ */
191
- zend_string * pname ;
192
-
188
+ {
193
189
if (ce -> ce_flags & ZEND_ACC_LINKED ) {
194
- ZEND_ASSERT (ce -> parent );
195
- pname = ce -> parent -> name ;
190
+ return ce -> parent ? ce -> parent -> name : NULL ;
196
191
} else {
197
- pname = ce -> parent_name ;
192
+ return ce -> parent_name ;
198
193
}
194
+ }
199
195
200
- /* If there is a parent, it must have a name */
201
- ZEND_ASSERT (pname );
202
- return pname ;
203
- }/* }}} */
204
-
205
- static
206
- zend_string * _resolve_parent_and_self (const zend_function * fe , zend_string * name )
196
+ static zend_string * _resolve_parent_and_self (const zend_function * fe , zend_string * name )
207
197
{ /* {{{ */
208
198
zend_class_entry * ce = fe -> common .scope ;
209
199
/* if there isn't a class then we shouldn't be resolving parent and self */
210
- ZEND_ASSERT (fe -> common . scope );
200
+ ZEND_ASSERT (ce );
211
201
212
202
switch (zend_get_class_fetch_type (name )) {
213
203
case ZEND_FETCH_CLASS_PARENT :
214
204
name = _get_parent_class_name (ce );
205
+ if (!name ) {
206
+ return NULL ;
207
+ }
215
208
break ;
216
209
217
210
case ZEND_FETCH_CLASS_SELF :
@@ -262,12 +255,19 @@ _inheritance_status _check_covariance(
262
255
}
263
256
264
257
if (ZEND_TYPE_IS_CLASS (fe_type )) {
265
- zend_string * fe_class_name =
266
- _resolve_parent_and_self (fe , ZEND_TYPE_NAME (fe_type ));
267
258
_inheritance_status code ;
259
+ zend_string * fe_class_name = _resolve_parent_and_self (fe , ZEND_TYPE_NAME (fe_type ));
260
+ if (!fe_class_name ) {
261
+ return INHERITANCE_UNRESOLVED ;
262
+ }
263
+
268
264
if (ZEND_TYPE_IS_CLASS (proto_type )) {
269
265
zend_string * proto_class_name =
270
266
_resolve_parent_and_self (proto , ZEND_TYPE_NAME (proto_type ));
267
+ if (!proto_class_name ) {
268
+ zend_string_free (fe_class_name );
269
+ return INHERITANCE_UNRESOLVED ;
270
+ }
271
271
272
272
if (zend_string_equals_ci (fe_class_name , proto_class_name )) {
273
273
code = INHERITANCE_SUCCESS ;
0 commit comments