From eb4cb92c2c45b0e7ee352af962de1a1931e02d5b Mon Sep 17 00:00:00 2001 From: "Wu, Yingcong" Date: Thu, 21 Nov 2024 18:28:53 -0800 Subject: [PATCH 1/2] check res before unpoison --- llvm/lib/Support/Compression.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Support/Compression.cpp b/llvm/lib/Support/Compression.cpp index badaf68ab59cd..6f3dd984416aa 100644 --- a/llvm/lib/Support/Compression.cpp +++ b/llvm/lib/Support/Compression.cpp @@ -206,12 +206,14 @@ Error zstd::decompress(ArrayRef Input, uint8_t *Output, const size_t Res = ::ZSTD_decompress( Output, UncompressedSize, (const uint8_t *)Input.data(), Input.size()); UncompressedSize = Res; + if (ZSTD_isError(Res)) { + return make_error(ZSTD_getErrorName(Res), + inconvertibleErrorCode()); + } // Tell MemorySanitizer that zstd output buffer is fully initialized. // This avoids a false report when running LLVM with uninstrumented ZLib. __msan_unpoison(Output, UncompressedSize); - return ZSTD_isError(Res) ? make_error(ZSTD_getErrorName(Res), - inconvertibleErrorCode()) - : Error::success(); + return Error::success(); } Error zstd::decompress(ArrayRef Input, From d710ec0b0c37b29d611fe63900b9ce42a8a9af4a Mon Sep 17 00:00:00 2001 From: "Wu, Yingcong" Date: Thu, 21 Nov 2024 18:35:59 -0800 Subject: [PATCH 2/2] format --- llvm/lib/Support/Compression.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/llvm/lib/Support/Compression.cpp b/llvm/lib/Support/Compression.cpp index 6f3dd984416aa..3979ca6acaf74 100644 --- a/llvm/lib/Support/Compression.cpp +++ b/llvm/lib/Support/Compression.cpp @@ -206,10 +206,9 @@ Error zstd::decompress(ArrayRef Input, uint8_t *Output, const size_t Res = ::ZSTD_decompress( Output, UncompressedSize, (const uint8_t *)Input.data(), Input.size()); UncompressedSize = Res; - if (ZSTD_isError(Res)) { + if (ZSTD_isError(Res)) return make_error(ZSTD_getErrorName(Res), inconvertibleErrorCode()); - } // Tell MemorySanitizer that zstd output buffer is fully initialized. // This avoids a false report when running LLVM with uninstrumented ZLib. __msan_unpoison(Output, UncompressedSize);