From 650475a98490e5fff40ca76c0ca6e46326610065 Mon Sep 17 00:00:00 2001 From: "florin.duban" Date: Thu, 27 Feb 2025 07:32:55 +0100 Subject: [PATCH] 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. --- packages/pinus-protobuf/lib/decoder.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pinus-protobuf/lib/decoder.ts b/packages/pinus-protobuf/lib/decoder.ts index 4c2406a9d..119540ef1 100644 --- a/packages/pinus-protobuf/lib/decoder.ts +++ b/packages/pinus-protobuf/lib/decoder.ts @@ -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);