Skip to content

Commit

Permalink
check res before unpoison
Browse files Browse the repository at this point in the history
  • Loading branch information
yingcong-wu committed Nov 22, 2024
1 parent 3f1e7ef commit eb4cb92
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions llvm/lib/Support/Compression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,14 @@ Error zstd::decompress(ArrayRef<uint8_t> 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<StringError>(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<StringError>(ZSTD_getErrorName(Res),
inconvertibleErrorCode())
: Error::success();
return Error::success();
}

Error zstd::decompress(ArrayRef<uint8_t> Input,
Expand Down

0 comments on commit eb4cb92

Please sign in to comment.