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
3 changes: 2 additions & 1 deletion programs/fileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,8 @@ static void FIO_adjustParamsForPatchFromMode(FIO_prefs_t* const prefs,
unsigned long long const maxSrcFileSize,
int cLevel)
{
unsigned const fileWindowLog = FIO_highbit64(maxSrcFileSize) + 1;
/* FIO_highbit64() requires v > 0 : an empty source only needs the smallest window */
unsigned const fileWindowLog = maxSrcFileSize ? FIO_highbit64(maxSrcFileSize) + 1 : ZSTD_WINDOWLOG_MIN;
ZSTD_compressionParameters const cParams = ZSTD_getCParams(cLevel, (size_t)maxSrcFileSize, (size_t)dictSize);
FIO_adjustMemLimitForPatchFromMode(prefs, dictSize, maxSrcFileSize);
if (fileWindowLog > ZSTD_WINDOWLOG_MAX)
Expand Down
10 changes: 10 additions & 0 deletions tests/cli-tests/compression/patch-from.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

set -e

# Test --patch-from with an empty file to patch
datagen -g1000 -P50 > ref
touch empty
zstd --patch-from=ref empty -o empty.zst
zstd -d --patch-from=ref empty.zst -o empty.out
cmp empty empty.out