From 49b44bff2b6257a119f9c6a342d6151c736586b8 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Fri, 4 Aug 2017 16:35:49 -0700 Subject: Fix the bug in php c extension that setting one field can change anotherĀ field's value. (#3455) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix the bug in php c extension that setting one field can change another field's value. The reason is that previously, in c extension, it was assumed that the order that fields were declared in php is the same as the order of fields in upb. This is not true. Now, for every field in upb, we will look up the actual property that is corresponding to the upb field. * Cleanup pull request * Fix indentation * Port to php5 * Port with php7.1 * Port to zts --- php/ext/google/protobuf/protobuf.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'php/ext/google/protobuf/protobuf.h') diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index 44a4155f..f9e9d229 100644 --- a/php/ext/google/protobuf/protobuf.h +++ b/php/ext/google/protobuf/protobuf.h @@ -151,7 +151,7 @@ #define PHP_PROTO_GLOBAL_UNINITIALIZED_ZVAL EG(uninitialized_zval_ptr) -#define OBJ_PROP(PROPERTIES, OFFSET) (PROPERTIES)->properties_table[OFFSET] +#define OBJ_PROP(OBJECT, OFFSET) &((OBJECT)->properties_table[OFFSET]) #define php_proto_zval_ptr_dtor(zval_ptr) \ zval_ptr_dtor(&(zval_ptr)) @@ -644,7 +644,7 @@ PHP_PROTO_WRAP_OBJECT_END MessageLayout* create_layout(const upb_msgdef* msgdef); void layout_init(MessageLayout* layout, void* storage, - CACHED_VALUE* properties_table PHP_PROTO_TSRMLS_DC); + zend_object* object PHP_PROTO_TSRMLS_DC); zval* layout_get(MessageLayout* layout, const void* storage, const upb_fielddef* field, CACHED_VALUE* cache TSRMLS_DC); void layout_set(MessageLayout* layout, MessageHeader* header, -- cgit v1.2.3