Skip to content

Commit 1c75f6d

Browse files
committed
Address review comments
1 parent 61d29fd commit 1c75f6d

File tree

6 files changed

+197
-185
lines changed

6 files changed

+197
-185
lines changed

Zend/zend_API.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4639,6 +4639,16 @@ ZEND_API zval *zend_read_property(zend_class_entry *scope, zend_object *object,
46394639
}
46404640
/* }}} */
46414641

4642+
ZEND_API zval *zend_read_property_deref(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, bool silent, zval *rv)
4643+
{
4644+
zval *value;
4645+
4646+
value = zend_read_property(scope, object, name, name_length, silent, rv);
4647+
ZVAL_DEREF(value);
4648+
4649+
return value;
4650+
}
4651+
46424652
ZEND_API zval *zend_read_static_property_ex(zend_class_entry *scope, zend_string *name, bool silent) /* {{{ */
46434653
{
46444654
zval *property;

Zend/zend_API.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ ZEND_API zend_result zend_update_static_property_stringl(zend_class_entry *scope
438438

439439
ZEND_API zval *zend_read_property_ex(zend_class_entry *scope, zend_object *object, zend_string *name, bool silent, zval *rv);
440440
ZEND_API zval *zend_read_property(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, bool silent, zval *rv);
441+
ZEND_API zval *zend_read_property_deref(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, bool silent, zval *rv);
441442

442443
ZEND_API zval *zend_read_static_property_ex(zend_class_entry *scope, zend_string *name, bool silent);
443444
ZEND_API zval *zend_read_static_property(zend_class_entry *scope, const char *name, size_t name_length, bool silent);

ext/soap/php_encoding.c

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -386,15 +386,15 @@ static xmlNodePtr master_to_xml_int(encodePtr encode, zval *data, int style, xml
386386
encodePtr enc = NULL;
387387
zval rv;
388388

389-
ztype = zend_read_property(soap_var_class_entry, Z_OBJ_P(data), "enc_type", sizeof("enc_type")-1, 1, &rv);
390-
if (ztype == NULL || Z_TYPE_P(ztype) != IS_LONG) {
389+
ztype = zend_read_property_deref(soap_var_class_entry, Z_OBJ_P(data), "enc_type", sizeof("enc_type")-1, 1, &rv);
390+
if (Z_TYPE_P(ztype) != IS_LONG) {
391391
soap_error0(E_ERROR, "Encoding: SoapVar has no 'enc_type' property");
392392
}
393393

394-
zstype = zend_read_property(soap_var_class_entry, Z_OBJ_P(data), "enc_stype", sizeof("enc_stype")-1, 1, &rv);
395-
if (zstype != NULL && Z_TYPE_P(zstype) == IS_STRING) {
396-
zns = zend_read_property(soap_var_class_entry, Z_OBJ_P(data), "enc_ns", sizeof("enc_ns")-1, 1, &rv);
397-
if (zns != NULL && Z_TYPE_P(zns) == IS_STRING) {
394+
zstype = zend_read_property_deref(soap_var_class_entry, Z_OBJ_P(data), "enc_stype", sizeof("enc_stype")-1, 1, &rv);
395+
if (Z_TYPE_P(zstype) == IS_STRING) {
396+
zns = zend_read_property_deref(soap_var_class_entry, Z_OBJ_P(data), "enc_ns", sizeof("enc_ns")-1, 1, &rv);
397+
if (Z_TYPE_P(zns) == IS_STRING) {
398398
enc = get_encoder(SOAP_GLOBAL(sdl), Z_STRVAL_P(zns), Z_STRVAL_P(zstype));
399399
} else {
400400
zns = NULL;
@@ -420,27 +420,27 @@ static xmlNodePtr master_to_xml_int(encodePtr encode, zval *data, int style, xml
420420
enc = encode;
421421
}
422422

423-
zdata = zend_read_property(soap_var_class_entry, Z_OBJ_P(data), "enc_value", sizeof("enc_value")-1, 1, &rv);
423+
zdata = zend_read_property_deref(soap_var_class_entry, Z_OBJ_P(data), "enc_value", sizeof("enc_value")-1, 1, &rv);
424424
node = master_to_xml(enc, zdata, style, parent);
425425

426426
if (style == SOAP_ENCODED || (SOAP_GLOBAL(sdl) && encode != enc)) {
427-
zstype = zend_read_property(soap_var_class_entry, Z_OBJ_P(data), "enc_stype", sizeof("enc_stype")-1, 1, &rv);
428-
if (zstype != NULL && Z_TYPE_P(zstype) == IS_STRING) {
429-
zns = zend_read_property(soap_var_class_entry, Z_OBJ_P(data), "enc_ns", sizeof("enc_ns")-1, 1, &rv);
430-
if (zns != NULL && Z_TYPE_P(zns) == IS_STRING) {
427+
zstype = zend_read_property_deref(soap_var_class_entry, Z_OBJ_P(data), "enc_stype", sizeof("enc_stype")-1, 1, &rv);
428+
if (Z_TYPE_P(zstype) == IS_STRING) {
429+
zns = zend_read_property_deref(soap_var_class_entry, Z_OBJ_P(data), "enc_ns", sizeof("enc_ns")-1, 1, &rv);
430+
if (Z_TYPE_P(zns) == IS_STRING) {
431431
set_ns_and_type_ex(node, Z_STRVAL_P(zns), Z_STRVAL_P(zstype));
432432
} else {
433433
set_ns_and_type_ex(node, NULL, Z_STRVAL_P(zstype));
434434
}
435435
}
436436
}
437437

438-
zname = zend_read_property(soap_var_class_entry, Z_OBJ_P(data), "enc_name", sizeof("enc_name")-1, 1, &rv);
439-
if (zname != NULL && Z_TYPE_P(zname) == IS_STRING) {
438+
zname = zend_read_property_deref(soap_var_class_entry, Z_OBJ_P(data), "enc_name", sizeof("enc_name")-1, 1, &rv);
439+
if (Z_TYPE_P(zname) == IS_STRING) {
440440
xmlNodeSetName(node, BAD_CAST(Z_STRVAL_P(zname)));
441441
}
442-
znamens = zend_read_property(soap_var_class_entry, Z_OBJ_P(data), "enc_namens", sizeof("enc_namens")-1, 1, &rv);
443-
if (znamens != NULL && Z_TYPE_P(znamens) == IS_STRING) {
442+
znamens = zend_read_property_deref(soap_var_class_entry, Z_OBJ_P(data), "enc_namens", sizeof("enc_namens")-1, 1, &rv);
443+
if (Z_TYPE_P(znamens) == IS_STRING) {
444444
xmlNsPtr nsp = encode_add_ns(node, Z_STRVAL_P(znamens));
445445
xmlSetNs(node, nsp);
446446
}
@@ -1170,11 +1170,10 @@ static void set_zval_property(zval* object, char* name, zval* val)
11701170
static zval* get_zval_property(zval* object, char* name, zval *rv)
11711171
{
11721172
if (Z_TYPE_P(object) == IS_OBJECT) {
1173-
zval *data = zend_read_property(Z_OBJCE_P(object), Z_OBJ_P(object), name, strlen(name), 1, rv);
1173+
zval *data = zend_read_property_deref(Z_OBJCE_P(object), Z_OBJ_P(object), name, strlen(name), 1, rv);
11741174
if (data == &EG(uninitialized_zval)) {
11751175
return NULL;
11761176
}
1177-
ZVAL_DEREF(data);
11781177
return data;
11791178
} else if (Z_TYPE_P(object) == IS_ARRAY) {
11801179
return zend_hash_str_find_deref(Z_ARRVAL_P(object), name, strlen(name));
@@ -3496,21 +3495,21 @@ static encodePtr get_array_type(xmlNodePtr node, zval *array, smart_str *type)
34963495
Z_OBJCE_P(tmp) == soap_var_class_entry) {
34973496
zval *ztype;
34983497

3499-
ztype = zend_read_property(soap_var_class_entry, Z_OBJ_P(tmp), "enc_type", sizeof("enc_type")-1, 1, &rv);
3500-
if (ztype == NULL || Z_TYPE_P(ztype) != IS_LONG) {
3498+
ztype = zend_read_property_deref(soap_var_class_entry, Z_OBJ_P(tmp), "enc_type", sizeof("enc_type")-1, 1, &rv);
3499+
if (Z_TYPE_P(ztype) != IS_LONG) {
35013500
soap_error0(E_ERROR, "Encoding: SoapVar has no 'enc_type' property");
35023501
}
35033502
cur_type = Z_LVAL_P(ztype);
35043503

3505-
ztype = zend_read_property(soap_var_class_entry, Z_OBJ_P(tmp), "enc_stype", sizeof("enc_stype")-1, 1, &rv);
3506-
if (ztype != NULL && Z_TYPE_P(ztype) == IS_STRING) {
3504+
ztype = zend_read_property_deref(soap_var_class_entry, Z_OBJ_P(tmp), "enc_stype", sizeof("enc_stype")-1, 1, &rv);
3505+
if (Z_TYPE_P(ztype) == IS_STRING) {
35073506
cur_stype = Z_STRVAL_P(ztype);
35083507
} else {
35093508
cur_stype = NULL;
35103509
}
35113510

3512-
ztype = zend_read_property(soap_var_class_entry, Z_OBJ_P(tmp), "enc_ns", sizeof("enc_ns")-1, 1, &rv);
3513-
if (ztype != NULL && Z_TYPE_P(ztype) == IS_STRING) {
3511+
ztype = zend_read_property_deref(soap_var_class_entry, Z_OBJ_P(tmp), "enc_ns", sizeof("enc_ns")-1, 1, &rv);
3512+
if (Z_TYPE_P(ztype) == IS_STRING) {
35143513
cur_ns = Z_STRVAL_P(ztype);
35153514
} else {
35163515
cur_ns = NULL;

0 commit comments

Comments
 (0)