Skip to content

Commit

Permalink
Fix potential crash by adding null check for proto options
Browse files Browse the repository at this point in the history
Added a null-safe operator to prevent accessing undefined properties in the decoder. This ensures stability when processing unexpected or incomplete protobuf structures.
  • Loading branch information
dubanflorin authored and whtiehack committed Feb 27, 2025
1 parent aecbf99 commit bf2e73f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/pinus-protobuf/lib/decoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class Decoder {
let tag = head.tag;
let name = protos.__tags[tag];

switch (protos[name].option) {
switch (protos[name]?.option) {
case 'optional':
case 'required':
msg[name] = this.decodeProp(protos[name].type, protos);
Expand Down

0 comments on commit bf2e73f

Please sign in to comment.