Fix memory leak in protobuf Descriptors.m, caused by missing synchronization when lazily generating list of ordered fields. The leak occurs when two threads try to access ordered fields at the same time.
@@ -256,6 +256,7 @@ int SerializationOrderComp(const void *a, const void *b) {
}
IOSObjectArray *CGPGetSerializationOrderFields(CGPDescriptor *descriptor) {
+ @synchronized(descriptor) {
IOSObjectArray *result = descriptor->serializationOrderFields_;
if (!result) {
result = [descriptor->fields_ copyWithZone:nil];
@@ -264,6 +265,7 @@ IOSObjectArray *CGPGetSerializationOrderFields(CGPDescriptor *descriptor) {
}
return result;
}
+}
J2OBJC_CLASS_TYPE_LITERAL_SOURCE(ComGoogleProtobufDescriptors_Descriptor)
