[llvm] 7f22cee - [gcov] Don't skip leading zeros when reading a string
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun May 10 10:18:23 PDT 2020
Author: Fangrui Song
Date: 2020-05-10T10:16:34-07:00
New Revision: 7f22ceeaae74911d97773644a1058659f329887e
URL: https://github.com/llvm/llvm-project/commit/7f22ceeaae74911d97773644a1058659f329887e
DIFF: https://github.com/llvm/llvm-project/commit/7f22ceeaae74911d97773644a1058659f329887e.diff
LOG: [gcov] Don't skip leading zeros when reading a string
Even a 2003 version of gcov_read_string does not have the behavior
described by rL204881. The wrong impression might come from
libclang_rt.profile (GCDAProfiling.c)'s corrupted output (since the
initial import rL144865). Note, the corrupted output crashes gcov.
Added:
Modified:
llvm/include/llvm/ProfileData/GCOV.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ProfileData/GCOV.h b/llvm/include/llvm/ProfileData/GCOV.h
index a8b8655f740f..1aabf3b65b62 100644
--- a/llvm/include/llvm/ProfileData/GCOV.h
+++ b/llvm/include/llvm/ProfileData/GCOV.h
@@ -187,12 +187,9 @@ class GCOVBuffer {
}
bool readString(StringRef &Str) {
- uint32_t Len = 0;
- // Keep reading until we find a non-zero length. This emulates gcov's
- // behaviour, which appears to do the same.
- while (Len == 0)
- if (!readInt(Len))
- return false;
+ uint32_t Len;
+ if (!readInt(Len) || Len == 0)
+ return false;
Len *= 4;
if (Buffer->getBuffer().size() < Cursor + Len) {
errs() << "Unexpected end of memory buffer: " << Cursor + Len << ".\n";
More information about the llvm-commits
mailing list