[clang] 8f43b84 - [ASTReader] Fix zlib header detection 0x78 after D137885
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 23 13:22:49 PST 2022
Author: Fangrui Song
Date: 2022-11-23T13:22:44-08:00
New Revision: 8f43b84322cc255414ad996834dff09e90dc19af
URL: https://github.com/llvm/llvm-project/commit/8f43b84322cc255414ad996834dff09e90dc19af
DIFF: https://github.com/llvm/llvm-project/commit/8f43b84322cc255414ad996834dff09e90dc19af.diff
LOG: [ASTReader] Fix zlib header detection 0x78 after D137885
D137885 picked an incorrect magic so it would fail when zstd is not
enabled.
Added:
Modified:
clang/lib/Serialization/ASTReader.cpp
Removed:
################################################################################
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index 367fbc06a8fe..8f7cb38c6a9f 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -1452,9 +1452,10 @@ bool ASTReader::ReadSLocEntry(int ID) {
unsigned RecCode = MaybeRecCode.get();
if (RecCode == SM_SLOC_BUFFER_BLOB_COMPRESSED) {
- // Inspect the first two bytes to
diff erentiate zlib (\x1f\x8b) and zstd.
+ // Inspect the first byte to
diff erentiate zlib (\x78) and zstd
+ // (little-endian 0xFD2FB528).
const llvm::compression::Format F =
- Blob.size() >= 2 && memcmp(Blob.data(), "\x1f\x8b", 2) == 0
+ Blob.size() > 0 && Blob.data()[0] == 0x78
? llvm::compression::Format::Zlib
: llvm::compression::Format::Zstd;
if (const char *Reason = llvm::compression::getReasonIfUnsupported(F)) {
More information about the cfe-commits
mailing list