follow the rabbit to fix potential issues

This commit is contained in:
dakai
2024-10-14 02:33:28 +08:00
parent e64a4f209c
commit 39f5d263f9
4 changed files with 13 additions and 24 deletions

View File

@@ -90,6 +90,9 @@ export function arrayBufferToWav(buffer: ArrayBuffer): ArrayBuffer {
// Helper function to write a string to the DataView
function writeString(view: DataView, offset: number, string: string) {
if (offset + string.length > view.byteLength) {
throw new Error("String is too long for the available space in DataView");
}
for (let i = 0; i < string.length; i++) {
view.setUint8(offset + i, string.charCodeAt(i));
}