Automated rollback of commit 0c013ec412.

PiperOrigin-RevId: 510136389
pull/11969/head
Protobuf Team Bot 2 years ago committed by Copybara-Service
parent c4ed948314
commit 2fb35fcf56
  1. 40
      objectivec/GPBMessage.m
  2. 5
      objectivec/GPBMessage_PackagePrivate.h
  3. 2
      objectivec/Tests/GPBMessageTests+Serialization.m

@ -2000,6 +2000,19 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
[input release];
}
#pragma mark - mergeDelimitedFrom
- (void)mergeDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry {
GPBCodedInputStreamState *state = &input->state_;
if (GPBCodedInputStreamIsAtEnd(state)) {
return;
}
NSData *data = GPBCodedInputStreamReadRetainedBytesNoCopy(state);
[self mergeFromData:data extensionRegistry:extensionRegistry];
[data release];
}
#pragma mark - Parse From Data Support
+ (instancetype)parseFromData:(NSData *)data error:(NSError **)errorPtr {
@ -2026,26 +2039,27 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
+ (instancetype)parseDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry
error:(NSError **)errorPtr {
GPBMessage *result = nil;
GPBMessage *message = [[[self alloc] init] autorelease];
@try {
uint64_t size = GPBCodedInputStreamReadUInt64(&input->state_);
size_t oldLimit = [input pushLimit:size];
result = [self parseFromCodedInputStream:input
extensionRegistry:extensionRegistry
error:errorPtr];
if (result) {
[input popLimit:oldLimit];
if (errorPtr) {
*errorPtr = nil;
}
[message mergeDelimitedFromCodedInputStream:input extensionRegistry:extensionRegistry];
if (errorPtr) {
*errorPtr = nil;
}
} @catch (NSException *exception) {
result = nil;
message = nil;
if (errorPtr) {
*errorPtr = ErrorFromException(exception);
}
}
return result;
#ifdef DEBUG
if (message && !message.initialized) {
message = nil;
if (errorPtr) {
*errorPtr = MessageError(GPBMessageErrorCodeMissingRequiredField, nil);
}
}
#endif
return message;
}
#pragma mark - Unknown Field Support

@ -80,6 +80,11 @@ typedef struct GPBMessage_Storage *GPBMessage_StoragePtr;
- (void)mergeFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry;
// Parses the next delimited message of this type from the input and merges it
// with this message.
- (void)mergeDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry;
- (void)addUnknownMapEntry:(int32_t)fieldNum value:(NSData *)data;
@end

@ -1276,7 +1276,7 @@
XCTAssertNil(result);
XCTAssertNotNil(error);
XCTAssertEqualObjects(error.domain, GPBCodedInputStreamErrorDomain);
XCTAssertEqual(error.code, GPBCodedInputStreamErrorInvalidSubsectionLimit);
XCTAssertEqual(error.code, GPBCodedInputStreamErrorInvalidSize);
}
#ifdef DEBUG

Loading…
Cancel
Save