aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/simple/simple_coder.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/liblzma/simple/simple_coder.c')
-rw-r--r--src/liblzma/simple/simple_coder.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/liblzma/simple/simple_coder.c b/src/liblzma/simple/simple_coder.c
index 4f499bef..ed2d7fb0 100644
--- a/src/liblzma/simple/simple_coder.c
+++ b/src/liblzma/simple/simple_coder.c
@@ -139,9 +139,11 @@ simple_code(void *coder_ptr, const lzma_allocator *allocator,
return ret;
}
- // Filter out[].
+ // Filter out[] unless there is nothing to filter.
+ // This way we avoid null pointer + 0 (undefined behavior)
+ // when out == NULL.
const size_t size = *out_pos - out_start;
- const size_t filtered = call_filter(
+ const size_t filtered = size == 0 ? 0 : call_filter(
coder, out + out_start, size);
const size_t unfiltered = size - filtered;