[llvm-commits] [llvm] r114723 - /llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.cpp
Evan Cheng
evan.cheng at apple.com
Thu Sep 23 22:18:35 PDT 2010
Author: evancheng
Date: Fri Sep 24 00:18:35 2010
New Revision: 114723
URL: http://llvm.org/viewvc/llvm-project?rev=114723&view=rev
Log:
Fix a potential null dereference bug.
Modified:
llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.cpp
Modified: llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.cpp?rev=114723&r1=114722&r2=114723&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.cpp Fri Sep 24 00:18:35 2010
@@ -53,6 +53,14 @@
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 @@
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 @@
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
More information about the llvm-commits
mailing list