We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 489bf51 commit 7faa0c4Copy full SHA for 7faa0c4
1 file changed
src/utils/KBinJSON.ts
@@ -505,6 +505,16 @@ function nodeToBinary(
505
binaryType = 'u8';
506
}
507
508
+ // Normalize missing or malformed content so kencode doesn't crash.
509
+ if (value === null || value === undefined) {
510
+ // If node is flagged as array (via __count), default to an empty array.
511
+ // Otherwise default to a single zero value for numeric types.
512
+ value = isArray ? [] : [0];
513
+ } else if (!Array.isArray(value)) {
514
+ // Ensure numeric/binary values are arrays for the writer APIs.
515
+ value = [value as number | bigint];
516
+ }
517
+
518
if (isArray) {
519
dataBuf.writeArray(binaryType as BinaryLengthType, value as (number | bigint)[]);
520
} else {
0 commit comments