forked from OSchip/llvm-project
[clangd] Don't use zlib when it's unavailable.
Without this patch `clangd` crashes at try to load compressed string table when `zlib` is not available. Example: - Build `clangd` with MinGW (`zlib` found) - Build index - Build `clangd` with Visual Studio compiler (`zlib` not found) - Try to load index Reviewed By: sammccall, adamcz Differential Revision: https://reviews.llvm.org/D87673
This commit is contained in:
parent
070b96962f
commit
d427df6369
|
@ -201,12 +201,13 @@ llvm::Expected<StringTableIn> readStringTable(llvm::StringRef Data) {
|
|||
llvm::SmallString<1> UncompressedStorage;
|
||||
if (UncompressedSize == 0) // No compression
|
||||
Uncompressed = R.rest();
|
||||
else {
|
||||
else if (llvm::zlib::isAvailable()) {
|
||||
if (llvm::Error E = llvm::zlib::uncompress(R.rest(), UncompressedStorage,
|
||||
UncompressedSize))
|
||||
return std::move(E);
|
||||
Uncompressed = UncompressedStorage;
|
||||
}
|
||||
} else
|
||||
return error("Compressed string table, but zlib is unavailable");
|
||||
|
||||
StringTableIn Table;
|
||||
llvm::StringSaver Saver(Table.Arena);
|
||||
|
|
Loading…
Reference in New Issue