diff options
author | Thomas Van Lenten <thomasvl@google.com> | 2017-01-04 15:03:42 -0500 |
---|---|---|
committer | Bo Yang <paulyang1211@gmail.com> | 2017-01-09 11:43:17 -0800 |
commit | 64cbfab937d3b9a176dfdf7d32c2ac8b29e30fca (patch) | |
tree | 446f4f94ccbaeaf3a5db331372c2f855c821c778 /objectivec/GPBMessage.m | |
parent | 77e434de36cf549bfba97782bfa6a58206b89e75 (diff) | |
download | protobuf-64cbfab937d3b9a176dfdf7d32c2ac8b29e30fca.tar.gz protobuf-64cbfab937d3b9a176dfdf7d32c2ac8b29e30fca.tar.bz2 protobuf-64cbfab937d3b9a176dfdf7d32c2ac8b29e30fca.zip |
Minor fix for autocreated object repeated fields and maps.
- If setting/clearing a repeated field/map that was objects, check the class
before checking the autocreator.
- Just to be paranoid, don’t mutate within copy/mutableCopy for the autocreated
classes to ensure there is less chance of issues if someone does something
really crazy threading wise.
- Some more tests for the internal AutocreatedArray/AutocreatedDictionary
classes to ensure things are working as expected.
- Add Xcode 8.2 to the full_mac_build.sh supported list.
Diffstat (limited to 'objectivec/GPBMessage.m')
-rw-r--r-- | objectivec/GPBMessage.m | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/objectivec/GPBMessage.m b/objectivec/GPBMessage.m index 4a6f0612..9660f1ed 100644 --- a/objectivec/GPBMessage.m +++ b/objectivec/GPBMessage.m @@ -1023,9 +1023,11 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) { if (arrayOrMap) { if (field.fieldType == GPBFieldTypeRepeated) { if (GPBFieldDataTypeIsObject(field)) { - GPBAutocreatedArray *autoArray = arrayOrMap; - if (autoArray->_autocreator == self) { - autoArray->_autocreator = nil; + if ([arrayOrMap isKindOfClass:[GPBAutocreatedArray class]]) { + GPBAutocreatedArray *autoArray = arrayOrMap; + if (autoArray->_autocreator == self) { + autoArray->_autocreator = nil; + } } } else { // Type doesn't matter, it is a GPB*Array. @@ -1037,9 +1039,11 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) { } else { if ((field.mapKeyDataType == GPBDataTypeString) && GPBFieldDataTypeIsObject(field)) { - GPBAutocreatedDictionary *autoDict = arrayOrMap; - if (autoDict->_autocreator == self) { - autoDict->_autocreator = nil; + if ([arrayOrMap isKindOfClass:[GPBAutocreatedDictionary class]]) { + GPBAutocreatedDictionary *autoDict = arrayOrMap; + if (autoDict->_autocreator == self) { + autoDict->_autocreator = nil; + } } } else { // Type doesn't matter, it is a GPB*Dictionary. |