aboutsummaryrefslogtreecommitdiff
path: root/php/ext/google/protobuf/encode_decode.c
diff options
context:
space:
mode:
authorPaul Yang <TeBoring@users.noreply.github.com>2017-08-04 16:35:49 -0700
committerGitHub <noreply@github.com>2017-08-04 16:35:49 -0700
commit49b44bff2b6257a119f9c6a342d6151c736586b8 (patch)
tree75fbf8e5e5b9645c1108b321cd803b697fda0b34 /php/ext/google/protobuf/encode_decode.c
parent21b0e5587c01948927ede9be789671ff116b7ad4 (diff)
downloadprotobuf-49b44bff2b6257a119f9c6a342d6151c736586b8.tar.gz
protobuf-49b44bff2b6257a119f9c6a342d6151c736586b8.tar.bz2
protobuf-49b44bff2b6257a119f9c6a342d6151c736586b8.zip
Fix the bug in php c extension that setting one field can change anotherĀ field's value. (#3455)
* 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
Diffstat (limited to 'php/ext/google/protobuf/encode_decode.c')
-rw-r--r--php/ext/google/protobuf/encode_decode.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/php/ext/google/protobuf/encode_decode.c b/php/ext/google/protobuf/encode_decode.c
index 4cb8997d..89e75d6a 100644
--- a/php/ext/google/protobuf/encode_decode.c
+++ b/php/ext/google/protobuf/encode_decode.c
@@ -716,7 +716,7 @@ static void *oneofbytes_handler(void *closure,
DEREF(message_data(msg), oneofdata->case_ofs, uint32_t) =
oneofdata->oneof_case_num;
DEREF(message_data(msg), oneofdata->ofs, CACHED_VALUE*) =
- &(msg->std.properties_table)[oneofdata->property_ofs];
+ OBJ_PROP(&msg->std, oneofdata->property_ofs);
return empty_php_string(DEREF(
message_data(msg), oneofdata->ofs, CACHED_VALUE*));
@@ -747,7 +747,7 @@ static void* oneofsubmsg_handler(void* closure, const void* hd) {
// Create new message.
DEREF(message_data(msg), oneofdata->ofs, CACHED_VALUE*) =
- &(msg->std.properties_table)[oneofdata->property_ofs];
+ OBJ_PROP(&msg->std, oneofdata->property_ofs);
ZVAL_OBJ(CACHED_PTR_TO_ZVAL_PTR(
DEREF(message_data(msg), oneofdata->ofs, CACHED_VALUE*)),
subklass->create_object(subklass TSRMLS_CC));