Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions c-ext/decompressor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1684,6 +1684,11 @@ Decompressor_multi_decompress_to_buffer(ZstdDecompressor *self, PyObject *args,
goto finally;
}

if (0 == frameCount) {
PyErr_SetString(PyExc_ValueError, "no source elements found");
goto finally;
}

/* We now have an array with info about our inputs and outputs. Feed it into
our generic decompression function. */
frameSources.frames = framePointers;
Expand Down
15 changes: 15 additions & 0 deletions tests/test_decompressor_multi_decompress_to_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ def test_invalid_inputs(self):
):
dctx.multi_decompress_to_buffer([b"foobarbaz"])

def test_empty_input(self):
dctx = zstd.ZstdDecompressor()
frames = [[], zstd.BufferWithSegments(b"", b"")]

for frame in frames:
for threads in (0, 2, -1):
for kwargs in ({}, {"decompressed_sizes": b""}):
with self.subTest(
frames=frame, threads=threads, kwargs=kwargs
):
with self.assertRaises(ValueError):
dctx.multi_decompress_to_buffer(
frame, threads=threads, **kwargs
)

def test_list_input(self):
cctx = zstd.ZstdCompressor()

Expand Down