forked from OSchip/llvm-project
[PGO] Don't call calloc(0, sizeof(ValueProfNode *))
A malloc implementation may return a pointer to some allocated space. It is undefined for libclang_rt.profile- to access the object - which actually happens in instrumentTargetValueImpl, where ValueCounters[CounterIndex] may access a ValueProfNode (from another allocated object) and crashes when the code accesses the object referenced by CurVNode->Next.
This commit is contained in:
parent
9e4ab439c2
commit
99ad956fda
|
@ -93,6 +93,8 @@ static int allocateValueProfileCounters(__llvm_profile_data *Data) {
|
|||
for (VKI = IPVK_First; VKI <= IPVK_Last; ++VKI)
|
||||
NumVSites += Data->NumValueSites[VKI];
|
||||
|
||||
if (NumVSites == 0)
|
||||
return 0;
|
||||
ValueProfNode **Mem =
|
||||
(ValueProfNode **)calloc(NumVSites, sizeof(ValueProfNode *));
|
||||
if (!Mem)
|
||||
|
|
Loading…
Reference in New Issue