Add strict slice range validation, fix RF64 reading error (fixes #146)

This commit is contained in:
Vanilagy
2025-09-25 10:26:44 +02:00
parent a043f410fd
commit 537119357d
5 changed files with 61 additions and 10 deletions
+2 -2
View File
@@ -155,7 +155,7 @@ export const writeBits = (bytes: Uint8Array, start: number, end: number, value:
};
export const toUint8Array = (source: AllowSharedBufferSource): Uint8Array => {
if (source instanceof Uint8Array) {
if (source.constructor === Uint8Array) { // We want a true Uint8Array, not something that extends it like Buffer
return source;
} else if (source instanceof ArrayBuffer) {
return new Uint8Array(source);
@@ -165,7 +165,7 @@ export const toUint8Array = (source: AllowSharedBufferSource): Uint8Array => {
};
export const toDataView = (source: AllowSharedBufferSource) => {
if (source instanceof DataView) {
if (source.constructor === DataView) {
return source;
} else if (source instanceof ArrayBuffer) {
return new DataView(source);