diff options
| author | Evan Cheng <evan.cheng@apple.com> | 2010-09-24 05:18:35 +0000 |
|---|---|---|
| committer | Evan Cheng <evan.cheng@apple.com> | 2010-09-24 05:18:35 +0000 |
| commit | b2a7dae5aecf58c776dbcf760df734c68bbf50b7 (patch) | |
| tree | 7021f6c19fbb4e2dc513b4c1197ac0f21416844c /lib | |
| parent | d2f3f4e7970fb33892bee50dca84b0d0b9416543 (diff) | |
| download | external_llvm-b2a7dae5aecf58c776dbcf760df734c68bbf50b7.zip external_llvm-b2a7dae5aecf58c776dbcf760df734c68bbf50b7.tar.gz external_llvm-b2a7dae5aecf58c776dbcf760df734c68bbf50b7.tar.bz2 | |
Fix a potential null dereference bug.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114723 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Target/ARM/ARMConstantPoolValue.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/Target/ARM/ARMConstantPoolValue.cpp b/lib/Target/ARM/ARMConstantPoolValue.cpp index f13ccc6..4ee71e2 100644 --- a/lib/Target/ARM/ARMConstantPoolValue.cpp +++ b/lib/Target/ARM/ARMConstantPoolValue.cpp @@ -53,6 +53,14 @@ const BlockAddress *ARMConstantPoolValue::getBlockAddress() const { return dyn_cast_or_null<BlockAddress>(CVal); } +static bool CPV_streq(const char *S1, const char *S2) { + if (S1 == S2) + return true; + if (S1 && S2 && strcmp(S1, S2) == 0) + return true; + return false; +} + int ARMConstantPoolValue::getExistingMachineCPValue(MachineConstantPool *CP, unsigned Alignment) { unsigned AlignMask = Alignment - 1; @@ -65,8 +73,8 @@ int ARMConstantPoolValue::getExistingMachineCPValue(MachineConstantPool *CP, if (CPV->CVal == CVal && CPV->LabelId == LabelId && CPV->PCAdjust == PCAdjust && - (CPV->S == S || strcmp(CPV->S, S) == 0) && - (CPV->Modifier == Modifier || strcmp(CPV->Modifier, Modifier) == 0)) + CPV_streq(CPV->S, S) && + CPV_streq(CPV->Modifier, Modifier)) return i; } } @@ -91,8 +99,8 @@ ARMConstantPoolValue::hasSameValue(ARMConstantPoolValue *ACPV) { if (ACPV->Kind == Kind && ACPV->CVal == CVal && ACPV->PCAdjust == PCAdjust && - (ACPV->S == S || strcmp(ACPV->S, S) == 0) && - (ACPV->Modifier == Modifier || strcmp(ACPV->Modifier, Modifier) == 0)) { + CPV_streq(ACPV->S, S) && + CPV_streq(ACPV->Modifier, Modifier)) { if (ACPV->LabelId == LabelId) return true; // Two PC relative constpool entries containing the same GV address or |
