aboutsummaryrefslogtreecommitdiff
path: root/objectivec/GPBCodedInputStream.m
diff options
context:
space:
mode:
authorThomas Van Lenten <thomasvl@google.com>2016-04-06 15:52:17 -0400
committerThomas Van Lenten <thomasvl@google.com>2016-04-06 15:52:17 -0400
commit28c5c25397030aa5db5c2ad33bad58f2fa50354a (patch)
treebde8d18a616fa07e84f5b4faf6a01411797991dc /objectivec/GPBCodedInputStream.m
parentf98d2f5147bdb8182bc63acf00c9be9be5956b5e (diff)
parentc9167f2acdd8ab477acb620cdd0bd231c8a0f3d0 (diff)
downloadprotobuf-28c5c25397030aa5db5c2ad33bad58f2fa50354a.tar.gz
protobuf-28c5c25397030aa5db5c2ad33bad58f2fa50354a.tar.bz2
protobuf-28c5c25397030aa5db5c2ad33bad58f2fa50354a.zip
Merge pull request #1391 from thomasvl/string_tweaks
ObjC String followups: one test case only addition, behavior change for invalid UTF-8
Diffstat (limited to 'objectivec/GPBCodedInputStream.m')
-rw-r--r--objectivec/GPBCodedInputStream.m7
1 files changed, 4 insertions, 3 deletions
diff --git a/objectivec/GPBCodedInputStream.m b/objectivec/GPBCodedInputStream.m
index eaa28e50..319ec15b 100644
--- a/objectivec/GPBCodedInputStream.m
+++ b/objectivec/GPBCodedInputStream.m
@@ -219,15 +219,16 @@ NSString *GPBCodedInputStreamReadRetainedString(
result = [[NSString alloc] initWithBytes:&state->bytes[state->bufferPos]
length:size
encoding:NSUTF8StringEncoding];
+ state->bufferPos += size;
if (!result) {
- result = @"";
#ifdef DEBUG
// https://developers.google.com/protocol-buffers/docs/proto#scalar
- NSLog(@"UTF8 failure, is some field type 'string' when it should be "
+ NSLog(@"UTF-8 failure, is some field type 'string' when it should be "
@"'bytes'?");
#endif
+ [NSException raise:NSParseErrorException
+ format:@"Invalid UTF-8 for a 'string'"];
}
- state->bufferPos += size;
}
return result;
}