Merge pull request #44 from frw/patch-1

fix: check string for null terminators
This commit is contained in:
David P.
2025-08-08 12:16:12 +02:00
committed by GitHub
+7 -1
View File
@@ -499,7 +499,13 @@ export class EBMLReader {
const { view, offset } = this.reader.getViewAndOffset(this.pos, this.pos + length);
this.pos += length;
return String.fromCharCode(...new Uint8Array(view.buffer, offset, length));
// Actual string length might be shorter due to null terminators
let strLength = 0;
while (strLength < length && view.getUint8(offset + strLength) !== 0) {
strLength += 1;
}
return String.fromCharCode(...new Uint8Array(view.buffer, offset, strLength));
}
readElementId() {