From e1dd78716699cc5e1734090e75d2a70f021ff4fd Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Tue, 14 Oct 2025 09:16:17 +0200 Subject: [PATCH] try to make even more robust --- shared/src/helper/BinaryData.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/shared/src/helper/BinaryData.ts b/shared/src/helper/BinaryData.ts index f1d16c4a0..70e4954fd 100644 --- a/shared/src/helper/BinaryData.ts +++ b/shared/src/helper/BinaryData.ts @@ -27,6 +27,12 @@ export class BinaryData { } asBuffer(): Buffer { + if (this.buf === undefined || !Buffer.isBuffer(this.buf)) { + if (this.buf) { + logging.error('invalid buf: ', this.buf) + } + throw new Error('buf is invalid') + } return this.buf } @@ -35,11 +41,14 @@ export class BinaryData { } isSame(other: BinaryData): boolean { - if (other === undefined || !(other instanceof BinaryData) || other.buf === undefined || !Buffer.isBuffer(other.buf)) { + if (other === undefined || !(other instanceof BinaryData)) { logging.error('other is invalid', other) return false } - return this.buf.compare(other.buf) === 0 + if (logging.isDebugEnabled()) { + logging.debug('compare hex: ', this.hex, other.asHex(), this.hex === other.asHex()) + } + return this.buf.compare(other.asBuffer()) === 0 } }