Skip to content

Commit 3198b5f

Browse files
committed
Fix UB in ZstdDecompressor.unused_data
1 parent ba1e1c1 commit 3198b5f

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

Modules/_zstd/decompressor.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,9 @@ _zstd_ZstdDecompressor_unused_data_get_impl(ZstdDecompressor *self)
588588

589589
PyMutex_Lock(&self->lock);
590590

591-
if (!self->eof) {
591+
// If we aren't done decompressing or no input data has been given,
592+
// return empty bytes
593+
if (!self->eof || self->input_buffer == NULL) {
592594
PyMutex_Unlock(&self->lock);
593595
return Py_GetConstant(Py_CONSTANT_EMPTY_BYTES);
594596
}

Tools/ubsan/suppressions.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ shift-base:Modules/_ctypes/cfield.c
1818
# Modules/_ctypes/cfield.c:640:1: runtime error: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'
1919
signed-integer-overflow:Modules/_ctypes/cfield.c
2020

21-
# Modules/_zstd/decompressor.c:598:56: runtime error: applying non-zero offset 18446744073709551615 to null pointer
22-
pointer-overflow:Modules/_zstd/decompressor.c
23-
2421
# Modules/_io/stringio.c:350:24: runtime error: addition of unsigned offset to 0x7fd01ec25850 overflowed to 0x7fd01ec2584c
2522
pointer-overflow:Modules/_io/stringio.c
2623

0 commit comments

Comments
 (0)