fix(vhd-lib/createVhdStreamWithLength): fix empty VHD handling

Follow-up of 4e9477f34

Introduced by c26a7a3e5
This commit is contained in:
Julien Fontanet
2023-03-31 10:02:19 +02:00
parent a4d1d41b6a
commit 506ef0b44f

View File

@@ -41,12 +41,14 @@ module.exports = async function createVhdStreamWithLength(stream) {
let streamPosition = 0
async function readStream(length) {
if (length !== 0) {
const chunk = await readChunkStrict(stream, length)
streamPosition += length
readBuffers.push(chunk)
return chunk
if (length === 0) {
return Buffer.alloc(0)
}
const chunk = await readChunkStrict(stream, length)
streamPosition += length
readBuffers.push(chunk)
return chunk
}
const footerBuffer = await readStream(FOOTER_SIZE)