Skip to content

Commit bf2e73f

Browse files
dubanflorinwhtiehack
authored andcommitted
Fix potential crash by adding null check for proto options
Added a null-safe operator to prevent accessing undefined properties in the decoder. This ensures stability when processing unexpected or incomplete protobuf structures.
1 parent aecbf99 commit bf2e73f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/pinus-protobuf/lib/decoder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class Decoder {
4848
let tag = head.tag;
4949
let name = protos.__tags[tag];
5050

51-
switch (protos[name].option) {
51+
switch (protos[name]?.option) {
5252
case 'optional':
5353
case 'required':
5454
msg[name] = this.decodeProp(protos[name].type, protos);

0 commit comments

Comments
 (0)