Skip to content

Commit

Permalink
New: Verify accepts non-null objects only, see #685
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO committed Feb 23, 2017
1 parent 2ddb76b commit 7f3f460
Show file tree
Hide file tree
Showing 16 changed files with 73 additions and 41 deletions.
26 changes: 17 additions & 9 deletions dist/light/protobuf.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/light/protobuf.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/light/protobuf.min.js

Large diffs are not rendered by default.

Binary file modified dist/light/protobuf.min.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion dist/light/protobuf.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/minimal/protobuf.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/minimal/protobuf.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified dist/minimal/protobuf.min.js.gz
Binary file not shown.
45 changes: 31 additions & 14 deletions dist/protobuf.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/protobuf.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions dist/protobuf.min.js

Large diffs are not rendered by default.

Binary file modified dist/protobuf.min.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion dist/protobuf.min.js.map

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,12 @@ export abstract class ReflectionObject {
*/
comment: string;

/**
* Defining file name.
* @type {?string}
*/
filename: string;

/**
* Reference to the root namespace.
* @name ReflectionObject#root
Expand Down
3 changes: 2 additions & 1 deletion src/type.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ Type.prototype.add = function add(object) {
// The root object takes care of adding distinct sister-fields to the respective extended
// type instead.

if (this.fieldsById[object.id])
// avoids calling the getter if not absolutely necessary because it's called quite frequently
if (this._fieldsById ? this._fieldsById[object.id] : this.fieldsById[object.id])
throw Error("duplicate id " + object.id + " in " + this);

if (object.parent)
Expand Down
8 changes: 4 additions & 4 deletions src/verifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ function genVerifyKey(gen, field, ref) {
function verifier(mtype) {
/* eslint-disable no-unexpected-multiline */

if (/* initializes */ !mtype.fieldsArray.length)
return util.codegen()("return null");
var gen = util.codegen("m");
var gen = util.codegen("m")
("if(typeof m!==\"object\"||m===null)")
("return%j", "object expected");

for (var i = 0; i < mtype._fieldsArray.length; ++i) {
for (var i = 0; i < /* initializes */ mtype.fieldsArray.length; ++i) {
var field = mtype._fieldsArray[i].resolve(),
ref = "m" + util.safeProp(field.name);

Expand Down

0 comments on commit 7f3f460

Please sign in to comment.