Skip to content

Commit 6d0a2df

Browse files
committed
Fix #94
1 parent 0a870e1 commit 6d0a2df

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufGenerator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,9 @@ protected void _encodeLongerString(String text) throws IOException
12891289

12901290
protected void _writeLengthPrefixed(byte[] data, int offset, int len) throws IOException
12911291
{
1292+
// 15-Jun-2017, tatu: [dataformats-binary#94]: need to ensure there is actually
1293+
// enough space for simple add; if not, need more checking
1294+
_ensureRoom(10); // max tag 5 bytes, ditto max length
12921295
int ptr = _writeTag(_currPtr);
12931296
ptr = ProtobufUtil.appendLengthLength(len, _currBuffer, ptr);
12941297

@@ -1783,7 +1786,7 @@ protected final void _ensureRoom(int needed) throws IOException
17831786

17841787
protected final void _ensureMore() throws IOException
17851788
{
1786-
// if not, either simple (flush), or
1789+
// if not, either simple (flush), or
17871790
final int start = _currStart;
17881791
final int currLen = _currPtr - start;
17891792

protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/failing/WriteLongString94Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void testLongerStrings() throws Exception {
3131
ProtobufSchema schema = MAPPER.generateSchemaFor(p.getClass());
3232
byte[] proto = MAPPER.writer(schema)
3333
.writeValueAsBytes(p);
34-
assertEquals(13, proto.length);
34+
assertEquals(2 * (7995 + 3), proto.length);
3535

3636
TwoStrings result = MAPPER.readerFor(p.getClass())
3737
.with(schema)

release-notes/CREDITS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,10 @@ Kenji Noguchi (knoguchi@github)
2020

2121
* Reported #70 (protobuf), contributed fix: Can't deserialize packed repeated field
2222
(2.8.9)
23+
24+
marsqing@github
25+
26+
* Reported #85: (protobuf) _decode32Bits() bug in ProtobufParser
27+
(2.8.9)
28+
* Reported #94: (protobuf) Should _ensureRoom in ProtobufGenerator.writeString()
29+
(2.8.10)

release-notes/VERSION

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ Modules:
1111

1212
2.9.0 (not yet released)
1313

14+
2.8.9.1 (not yet released)
15+
16+
#94: Should _ensureRoom in ProtobufGenerator.writeString()
17+
(reported by marsqing@github)
18+
1419
2.8.9 (12-Jun-2017)
1520

1621
#72: (protobuf) parser fails with /* comment */

0 commit comments

Comments
 (0)