.zst, .br: avoid setting of size hint for unknown size by -si, since unpackSize will be supplied as -1 (UINT64_MAX)

This commit is contained in:
sebres
2023-09-14 19:51:36 +02:00
parent 8a5e1c82db
commit 1eca571ea2
3 changed files with 5 additions and 4 deletions

View File

@@ -15,7 +15,8 @@ CEncoder::CEncoder():
_numThreads(NWindows::NSystem::GetNumberOfProcessors()),
_Long(-1),
_WindowLog(-1),
_ctx(NULL)
_ctx(NULL),
unpackSize(0)
{
_props.clear();
}

View File

@@ -263,7 +263,7 @@ STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream,
if (ZSTD_isError(err)) return E_INVALIDARG;
}
if (unpackSize) {
if (unpackSize && unpackSize != (UInt64)(Int64)-1) { // size is known
err = ZSTD_CCtx_setParameter(_ctx, ZSTD_c_srcSizeHint, (int)(unpackSize <= INT_MAX ? unpackSize : INT_MAX));
if (ZSTD_isError(err)) return E_INVALIDARG;
}