aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYilun Chong <yilunchong@google.com>2018-07-31 11:35:48 -0700
committerYilun Chong <yilunchong@google.com>2018-07-31 11:35:48 -0700
commit82a4e4e3d3abf9c40bdbc54135d75d27eb5ef5a0 (patch)
treebb82e801f59f6fb6da8f817f19e9975e25d07822
parent8705adc2289aca42b9ec54e0e9cdaf869beceb63 (diff)
downloadprotobuf-82a4e4e3d3abf9c40bdbc54135d75d27eb5ef5a0.tar.gz
protobuf-82a4e4e3d3abf9c40bdbc54135d75d27eb5ef5a0.tar.bz2
protobuf-82a4e4e3d3abf9c40bdbc54135d75d27eb5ef5a0.zip
Fix js reader.js's skipGroup
-rw-r--r--js/binary/reader.js12
-rw-r--r--js/binary/reader_test.js2
-rw-r--r--js/package.json2
3 files changed, 8 insertions, 8 deletions
diff --git a/js/binary/reader.js b/js/binary/reader.js
index 2dc3eb70..5e48f19b 100644
--- a/js/binary/reader.js
+++ b/js/binary/reader.js
@@ -389,7 +389,7 @@ jspb.BinaryReader.prototype.skipFixed64Field = function() {
*/
jspb.BinaryReader.prototype.skipGroup = function() {
// Keep a stack of start-group tags that must be matched by end-group tags.
- var nestedGroups = [this.nextField_];
+ var previousField = this.nextField_;
do {
if (!this.nextField()) {
goog.asserts.fail('Unmatched start-group tag: stream EOF');
@@ -397,19 +397,17 @@ jspb.BinaryReader.prototype.skipGroup = function() {
return;
}
if (this.nextWireType_ ==
- jspb.BinaryConstants.WireType.START_GROUP) {
- // Nested group start.
- nestedGroups.push(this.nextField_);
- } else if (this.nextWireType_ ==
jspb.BinaryConstants.WireType.END_GROUP) {
// Group end: check that it matches top-of-stack.
- if (this.nextField_ != nestedGroups.pop()) {
+ if (this.nextField_ != previousField) {
goog.asserts.fail('Unmatched end-group tag');
this.error_ = true;
return;
}
+ return;
}
- } while (nestedGroups.length > 0);
+ this.skipField();
+ } while (true);
};
diff --git a/js/binary/reader_test.js b/js/binary/reader_test.js
index 95711385..7fdf81b9 100644
--- a/js/binary/reader_test.js
+++ b/js/binary/reader_test.js
@@ -680,8 +680,10 @@ describe('binaryReaderTest', function() {
var dummyMessage = /** @type {!jspb.BinaryMessage} */({});
writer.writeGroup(5, dummyMessage, function() {
writer.writeInt64(42, 42);
+ writer.writeString(43, 'The quick brown fox jumps over the lazy dog');
writer.writeGroup(6, dummyMessage, function() {
writer.writeInt64(84, 42);
+ writer.writeString(85, 'The quick brown fox jumps over the lazy dog');
});
});
diff --git a/js/package.json b/js/package.json
index 325f2dcc..d2afcb3c 100644
--- a/js/package.json
+++ b/js/package.json
@@ -22,5 +22,5 @@
"url": "https://github.com/google/protobuf/tree/master/js"
},
"author": "Google Protocol Buffers Team",
- "license" : "BSD-3-Clause"
+ "license": "BSD-3-Clause"
}