Commit 77749477 for xz
commit 777494777069958a3fa6189d3a4267d762f0fa65
Author: Lasse Collin <lasse.collin@tukaani.org>
Date: Tue Nov 17 18:43:05 2026 +0200
liblzma: Make lzma_easy_encoder_memusage() return UINT64_MAX on error
Very early version of the code used uint32_t and UINT32_MAX. The function
name and return type were changed but the error code wasn't.
Reported-by: GitHub user katie-andtruth
diff --git a/src/liblzma/api/lzma/container.h b/src/liblzma/api/lzma/container.h
index ea773946..790a35fc 100644
--- a/src/liblzma/api/lzma/container.h
+++ b/src/liblzma/api/lzma/container.h
@@ -265,6 +265,8 @@ typedef struct {
*
* \return Number of bytes of memory required for the given
* preset when encoding or UINT64_MAX on error.
+ * liblzma 5.8.4 and older had a bug: they returned
+ * UINT32_MAX on error instead of UINT64_MAX.
*/
extern LZMA_API(uint64_t) lzma_easy_encoder_memusage(uint32_t preset)
lzma_nothrow lzma_attr_pure;
diff --git a/src/liblzma/common/easy_encoder_memusage.c b/src/liblzma/common/easy_encoder_memusage.c
index 1184ac66..fe4eb322 100644
--- a/src/liblzma/common/easy_encoder_memusage.c
+++ b/src/liblzma/common/easy_encoder_memusage.c
@@ -17,7 +17,7 @@ lzma_easy_encoder_memusage(uint32_t preset)
{
lzma_options_easy opt_easy;
if (lzma_easy_preset(&opt_easy, preset))
- return UINT32_MAX;
+ return UINT64_MAX;
return lzma_raw_encoder_memusage(opt_easy.filters);
}