diff options
Diffstat (limited to 'objectivec')
-rw-r--r-- | objectivec/GPBCodedOutputStream.m | 5 | ||||
-rw-r--r-- | objectivec/Tests/GPBCodedOuputStreamTests.m | 10 | ||||
-rw-r--r-- | objectivec/google/protobuf/FieldMask.pbobjc.h | 4 |
3 files changed, 16 insertions, 3 deletions
diff --git a/objectivec/GPBCodedOutputStream.m b/objectivec/GPBCodedOutputStream.m index f832e8a6..b846c2fc 100644 --- a/objectivec/GPBCodedOutputStream.m +++ b/objectivec/GPBCodedOutputStream.m @@ -942,7 +942,10 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, state_.position = length; } else { // Write is very big. Let's do it all at once. - [state_.output write:((uint8_t *)value) + offset maxLength:length]; + NSInteger written = [state_.output write:((uint8_t *)value) + offset maxLength:length]; + if (written != (NSInteger)length) { + [NSException raise:GPBCodedOutputStreamException_WriteFailed format:@""]; + } } } } diff --git a/objectivec/Tests/GPBCodedOuputStreamTests.m b/objectivec/Tests/GPBCodedOuputStreamTests.m index 878e7aa9..109239d5 100644 --- a/objectivec/Tests/GPBCodedOuputStreamTests.m +++ b/objectivec/Tests/GPBCodedOuputStreamTests.m @@ -423,4 +423,14 @@ } } +- (void)testThatItThrowsWhenWriteRawPtrFails { + NSOutputStream *output = [NSOutputStream outputStreamToMemory]; + GPBCodedOutputStream *codedOutput = + [GPBCodedOutputStream streamWithOutputStream:output bufferSize:0]; // Skip buffering. + [output close]; // Close the output stream to force failure on write. + const char *cString = "raw"; + XCTAssertThrowsSpecificNamed([codedOutput writeRawPtr:cString offset:0 length:strlen(cString)], + NSException, GPBCodedOutputStreamException_WriteFailed); +} + @end diff --git a/objectivec/google/protobuf/FieldMask.pbobjc.h b/objectivec/google/protobuf/FieldMask.pbobjc.h index 75cf856c..74aa8568 100644 --- a/objectivec/google/protobuf/FieldMask.pbobjc.h +++ b/objectivec/google/protobuf/FieldMask.pbobjc.h @@ -255,8 +255,8 @@ typedef GPB_ENUM(GPBFieldMask_FieldNumber) { * * ## Field Mask Verification * - * The implementation of the all the API methods, which have any FieldMask type - * field in the request, should verify the included field paths, and return + * The implementation of any API method which has a FieldMask type field in the + * request should verify the included field paths, and return an * `INVALID_ARGUMENT` error if any path is duplicated or unmappable. **/ @interface GPBFieldMask : GPBMessage |